import {mapGetters} from 'vuex'

import moment from 'moment';
import {EDITADURL,IESACCOUNT, ADVER,DMPURL,CATEGORYURL,FLOWPACKAGE,ADCONVERT,CITYGET,ACCOUNTURL,PACKAGELIST,AUDIENCE,ADDPACKAGE,AWEMELEVEL,KEYWORDSURL,INTERESTURL,INTERESTKEY,SITEURL,THIRDSITE} from "@/services/api";
import linkage from '@/components/multistage/linkage';
import {ajaxget, ajaxnoparams, ajaxrequest,ajaxparems } from "@/services/ajaxrequest";
var options = [];
var data = new Object();
const datalist = [];
const city = [];
var county = [];
var agearr = [];
var tiktoklist = [];
var columns  = [
	{
    title: '人群包',
    dataIndex: 'name',
  },
  {
    title: '属性',
    dataIndex: 'tag',
  },
];

var talentcolumns =[
  {
      // fixed: 'left',
      title: '达人分类',
      scopedSlots: { customRender: 'name' },
  },
];
var sontalentcolumns = [
{
      fixed: 'left',
      title: '个人管理',
      scopedSlots: { customRender: 'name' },
  },
]

var threetalentcolumns = [
{
      fixed: 'left',
      title: '按类型',
      scopedSlots: { customRender: 'name' },
  },
];

var directional  = [
	{
    title: '定向信息',
    dataIndex: 'name',
  },
  {
    title: '属性',
    dataIndex: 'tag',
  },
];


const tagslist = [];
var selectedRows = [];
var selectedRowss = [];
var categories =[
    {
        fixed: 'left',
        title: '行为类目词',
        dataIndex: 'name',
        scopedSlots: { customRender: 'name' },
    },
];
const categoriess = [
    {
        fixed: 'left',
        title: '关键词',
        dataIndex: 'name',
        scopedSlots: { customRender: 'name' },
    },
];
const soncategories = [
    {
        fixed: 'left',
        title: '行为类子目词',
        dataIndex: 'name',
        scopedSlots: { customRender: 'name' },
    },
];
var categorieslist = [];
var soncategorieslist = [];
var rowcategorieslist = [];
var rowpackagelists = [];
const packagelabel =[
    {
        title: '媒体包',
        dataIndex: 'name',
      },
      {
        title: '属性',
        dataIndex: 'tag',
      },
];
var packagelist = [];
var rowpackagelist = [];
var platform = [];
var networks = [];
var directionallist =[];

const articlelabel = [
  {
    title: '文章分类',
    dataIndex: 'name',
  },
];

var articlelist = [
  {
    key: '1',
    name: '娱乐',
    value:'ENTERTAINMENT'
  },
  {
    key: '2',
    name: '社会',
    value:'SOCIETY'
  },
  {
    key: '3',
    name: '汽车',
    value:'CARS'
  }, {
    key: '4',
    name: '国际',
    value:'INTERNATIONAL'
  }, {
    key: '5',
    name: '历史',
    value:'HISTORY'
  }, {
    key: '6',
    name: '体育',
    value:'SPORTS'
  }, {
    key: '7',
    name: '健康',
    value:'HEALTH'
  }, {
    key: '8',
    name: '军事',
    value:'MILITARY'
  }, {
    key: '9',
    name: '情感',
    value:'EMOTION'
  }, {
    key: '10',
    name: '时尚',
    value:'FASHION'
  }, {
    key: '11',
    name: '育儿',
    value:'PARENTING'
  }, {
    key: '12',
    name: '财经',
    value:'FINANCE'
  }, {
    key: '13',
    name: '搞笑',
    value:'AMUSEMENT'
  }, {
    key: '14',
    name: '数码',
    value:'DIGITAL'
  }, {
    key: '15',
    name: '探索',
    value:'EXPLORE'
  }, {
    key: '16',
    name: '旅游',
    value:'TRAVEL'
  }, {
    key: '17',
    name: '星座',
    value:'CONSTELLATION'
  }, {
    key: '18',
    name: '故事',
    value:'STORIES'
  }, {
    key: '19',
    name: '科技',
    value:'TECHNOLOGY'
  }, {
    key: '20',
    name: '美食',
    value:'GOURMET'
  }, {
    key: '21',
    name: '文化',
    value:'CULTURE'
  }, {
    key: '22',
    name: '家具',
    value:'HOME'
  },{
    key: '23',
    name: '电影',
    value:'MOVIE'
  },{
    key: '24',
    name: '宠物',
    value:'PETS'
  },{
    key: '25',
    name: '游戏',
    value:'GAMES'
  },{
    key: '26',
    name: '瘦身',
    value:'WEIGHT_LOSING'
  },{
    key: '27',
    name: '奇葩',
    value:'FREAK'
  },{
    key: '28',
    name: '教育',
    value:'EDUCATION'
  },{
    key: '29',
    name: '房产',
    value:'ESTATE'
  },{
    key: '30',
    name: '科学',
    value:'SCIENCE'
  },{
    key: '31',
    name: '摄影',
    value:'PHOTOGRAPHY'
  },{
    key: '32',
    name: '养生',
    value:'REGIMEN'
  },{
    key: '33',
    name: '美文',
    value:'ESSAY'
  },{
    key: '34',
    name: '收藏',
    value:'COLLECTION'
  },{
    key: '35',
    name: '动漫',
    value:'ANIMATION'
  },{
    key: '35',
    name: '漫画',
    value:'COMICS'
  },{
    key: '36',
    name: '小窍门',
    value:'TIPS'
  },{
    key: '37',
    name: '设计',
    value:'DESIGN'
  },
  {
    key: '38',
    name: '本地',
    value:'LOCAL'
  },
  {
    key: '39',
    name: '法制',
    value:'LAWS'
  },
  {
    key: '40',
    name: '政务',
    value:'GOVERNMENT'
  },
  {
    key: '41',
    name: '商业',
    value:'BUSINESS'
  },
  {
    key: '42',
    name: '职场',
    value:'WORKPLACE'
  },
  {
    key: '43',
    name: '辟谣',
    value:'RUMOR_CRACKER'
  },
  {
    key: '44',
    name: '毕业生',
    value:'GRADUATES'
  },
];
var rowarticlelist = [];
var operator = [];
var monthlist = [];
const brandlabel = [
  {
    title: '手机品牌',
    dataIndex: 'name',
  },
];

const brandlist = [
  {
    key: '1',
    name: '荣耀',
    value:'HONOR'
  },{
    key: '2',
    name: '苹果',
    value:'APPLE'
  },{
    key: '3',
    name: '华为',
    value:'HUAWEI'
  },{
    key: '4',
    name: '小米',
    value:'XIAOMI'
  },{
    key: '5',
    name: '三星',
    value:'SAMSUNG'
  },{
    key: '6',
    name: 'OPPO',
    value:'OPPO'
  },{
    key: '7',
    name: 'VIVO',
    value:'VIVO'
  },{
    key: '8',
    name: '魅族',
    value:'MEIZU'
  },{
    key: '9',
    name: '金立',
    value:'GIONEE'
  },{
    key: '10',
    name: '酷派',
    value:'COOLPAD'
  },{
    key: '11',
    name: '联想',
    value:'LENOVO'
  },{
    key: '12',
    name: '乐视',
    value:'LETV'
  },{
    key: '13',
    name: '中兴',
    value:'ZTE'
  },{
    key: '14',
    name: '中国移动',
    value:'CHINAMOBILE'
  },{
    key: '15',
    name: 'HTC',
    value:'HTC'
  },{
    key: '16',
    name: '小辣椒',
    value:'PEPPER'
  },{
    key: '17',
    name: '努比亚',
    value:'NUBIA'
  },{
    key: '18',
    name: '海信',
    value:'HISENSE'
  },{
    key: '19',
    name: '奇酷',
    value:'QIKU'
  },{
    key: '20',
    name: 'TCL',
    value:'TCL'
  },{
    key: '21',
    name: '索尼',
    value:'SONY'
  },
  {
    key: '22',
    name: '锤子手机',
    value:'SMARTISAN'
  }, {
    key: '23',
    name: '360手机',
    value:'360'
  }, {
    key: '24',
    name: '一加手机',
    value:'ONEPLUS'
  }, {
    key: '25',
    name: 'LG',
    value:'LG'
  }, {
    key: '26',
    name: '摩托罗拉',
    value:'MOTO'
  }, {
    key: '27',
    name: '诺基亚',
    value:'NOKIA'
  }, {
    key: '29',
    name: '谷歌',
    value:'GOOGLE'
  },
];
const rowbrandlist = [];
var pricearr= [];
var strnum = [];
var enabledlabel = [
  {
    title: '可放开定向',
    dataIndex: 'name',
  },
];
var enabledlist = [
  {
    key: '1',
    name: '地域',
    value:'REGION'
  },{
    key: '2',
    name: '性别',
    value:'GENDER'
  },{
    key: '3',
    name: '年龄',
    value:'AGE'
  },{
    key: '4',
    name: '兴趣分类',
    value:'AD_TAG'
  },{
    key: '5',
    name: '兴趣关键词',
    value:'INTEREST_TAG'
  },{
    key: '6',
    name: '自定人群-定向',
    value:'CUSTOM_AUDIENCE'
  },{
    key: '7',
    name: '行为兴趣',
    value:'INTEREST_ACTION'
  },
];
var rowenabledlist = [];
var radiolist = [];
const treeData = [];


const columnscity = [
	{
	  title: '省份',
	  // dataIndex: 'name',
	  scopedSlots: { customRender: 'name' },
	},
];
  
const soncolumns = [
	{
	  title: '城市',
	  dataIndex: 'name',
	  scopedSlots: { customRender: 'name' },
	},
];
  
const grandcolumns = [
	{
	  title: '城市',
	  dataIndex: 'name',
	  scopedSlots: { customRender: 'name' },
	},
];

export default {
  components: {linkage},
  created() {
	// this.form.setFieldsValue({'istemp':0});
	
    // var queid = this.$route.query.campaign_id;
    // var landing_types = this.$route.query.landing_type;
    // this.id = queid;
    // this.ids = queid;
    // this.landing_type = landing_types;
    this.pageinfo();
    this.getTime();
  },
  beforeCreate() {
	this.form = this.$form.createForm(this);
	this.form2 = this.$form.createForm(this);
	this.form3 = this.$form.createForm(this);
	this.form4 = this.$form.createForm(this);
	this.form5 = this.$form.createForm(this);
	this.form6 = this.$form.createForm(this);
	this.form7 = this.$form.createForm(this);
	this.form8 = this.$form.createForm(this);
	this.formaudience = this.$form.createForm(this);
  },
  inject:['reload'],
  data() {
    return {
		spinning:true,
        ids: [],
	    id: "",
	    landing_type:'',//广告组类型
        options: options,
        delivery_range: "DEFAULT",//范围
	    union_video_type:'REWARDED_VIDEO',//形式
	    pricings:'PRICING_OCPM',//目标
        download_type:'DOWNLOAD_URL',//下载链接
        openurl:1,
        promotion_type:'AWEME_HOME_PAGE',//落地页
        tiktokbox:false,
        tiktoklist,
        treeData:treeData,
        externaltype:false,
	    district:"NONE",//定向地域
	    gender:"NONE",//性别
	  label:{
            label1:false,
            label2:false,
            label3:false,
            label4:false,
            label5:false,
            android:false,
            iOS:false,
            PC:false,
            wifi:false,
            twog:false,
            threeg:false,
            forg:false,
            MOBILE:false,
            UNICOM:false,
            TELCOM:false,
            WITH_IN_A_MONTH:false,
            ONE_MONTH_2_THREE_MONTH:false,
            THREE_MONTH_EAILIER:false,
    	},
      agearr,//年龄多选
      platform,//平台多选
	  retargeting:"NONE",//自定义人群
	  retargeting_tags:"retargeting_tags_include",//定向逻辑
        columns,
        directional,//定向包
	  tagslist,//人群包列表
      interest:"UNLIMITED",//兴趣
      tiktok:"NONE",
      superior:"NONE",
      packages:'flow_package',
      converted:'NO_EXCLUDE',
      isconverted:false,
      article:0,
      brand:0,
      launchprice:0,
      marks: {
        0: '不限',
        500: '',
        1000: '',
        1500: '',
        2000: '2000以内',
        2500: '',
        3000: '',
        3500: '',
        4000: '',
        4500: '',
        5000: '5000以内',
        6000: '',
        7000: '',
        8000: '',
        9000: '',
        10000: '1万以内',
        11000: {
          style: {
            color: '#f50',
          },
          label: <strong>不限</strong>,
        },
      },
      enableds:0,
      sceneselect:'SMART_BID_CUSTOM',
      adjust:'FLOW_CONTROL_MODE_FAST',
      schedule_type:'SCHEDULE_FROM_NOW',
      nowTime:"",
      dateFormat: 'YYYY-MM-DD',
	  name:'',
	  names:'',
      monstform:false,
      external:true,
      radiolist,
      appsdk:true,
      appapi:true,
      appdirect:true,
      track:false,
      tracks:false,
      isblock: "none",
	  idv:'',
      info: "",
	  datalist,
      checkedList: [],
      indeterminate: true,
      checkAll: false,
	  city:city,
	  county,
	  selectedRows,
      selectedRowss,
      categories,
      categorieslist,
      rowcategorieslist,
      pages:false,
      soncategories,
      soncategorieslist,
      categoriess,
      dis:false,
      packagelabel,
      packagelist,
      rowpackagelist,
      rowpackagelists,
      networks,
      directionallist,
      articlelabel,
      articlelist,
      rowarticlelist,
      operator,
      monthlist,
      brandlabel,
      brandlist,
      rowbrandlist,
      pricearr,
      strnum,
      enabledlabel,
      enabledlist,
      rowenabledlist,
      datainfo:[],
      typeinfo:0,
      account:[],
      campaignlist:[],
      pagesinfo:[],
      landinginfo:'',
      scene:'',
      dstion:false,
      checkdstion:false,
      dstionlist:[],
      rangetype:'APP_IOS',
      audiencelist:[],
      visible:false,
      logging:false,
      estimate:{},
		checkloading:false,
		confirmLoading:false,
		disnum:"00",
		disid:'',
		copyvis:false,
		copyindex:'',
		copynames:'',
		objlist:[],
		newdislist:[],

		rowtiktoktalentlist:[],
		rowtiktoktalentlists:[],
		threetiktoktalent:[],
		talentcolumns,
		sontalentcolumns,
		threetalentcolumns,
		tiktoktalent:[],
		sontiktoktalent:[],
		rowthreetiktoktalent:[],
		disidslist:[],

			// 遍历数组2
			arr2:[],
			// 三级
			arr3:[],
			is_checked_1:false,
			is_checked_2:false,
			is_checked_3:false,
			// 记录第一个选中数组的索引
			arr1CheckedIndex:null,
			// 记录第二格数组
			arr2CheckedIndex:null,
			// 第三个数组的索引值
			arr3CheckedIndex: null,
			// 记录选中的title
			titleArr: [],
			catewords:[],//已选行为类目词
	
			// 遍历数组2
			array2:[],
			// 三级
			array3:[],
			is_checked_s1:false,
			is_checked_s2:false,
			is_checked_s3:false,
			// 记录第一个选中数组的索引
			array1CheckedIndex:null,
			// 记录第二格数组
			array2CheckedIndex:null,
			// 第三个数组的索引值
			array3CheckedIndex: null,
			// 记录选中的title
			titleArray: [],//
			catewordslist:[],//已选兴趣类目词
			action_days:30,
			action_scene:'',
			keyswordlist:[],//兴趣关键词列表
			datakeyword:[],//已选行为关键词
			datakey:[],//已选兴趣关键词
			interestkeyword:[],
			action_key:'action_categories',
			keyvalue:'',
			interestvalue:'',
			interestlist:[],

			columnscity,
			soncolumns,
			grandcolumns,
			// pages:false,
			sontable:false,
			grandtable:false,
			sontreeData:[],
			grandtreeData:[],
			citylist:[],//选中的城市
			is_checkedcity:false,
			countylist:[],
			namelist:[],
			
			visibleld:false,
			visiblexz:false,
			useldylsit:[],
			externalurl:'',
			downloadurl:'',
			datayy:[],
			audiencecheck:false,
			loadinglist:false,
			audienceloading:false,
			sontree:[],
			location_type:'CURRENT',
    };
  },
  methods: {
	moment,
	onuseldy(){
		//落地页选择已有
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		ajaxrequest(advertiser_id, SITEURL,"").then((res) => {
			var result=res.data;
			if(result.code =="SUCCESS"){
			  this.useldylsit = result.data.list;
			}else{
			  this.$message.error(result.message,3);
			}
		})
		this.visibleld = true;
	},
	onlanpage(e){
		//落地页筛选
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		if(e ==1){
			// 橙子建站落地页
			ajaxrequest(advertiser_id, SITEURL,"").then((res) => {
				var result=res.data;
				if(result.code =="SUCCESS"){
				  this.useldylsit = result.data.list;
				}else{
				  this.$message.error(result.message,3);
				}
			})
		}else{
			// 第三方落地页
			ajaxrequest(advertiser_id, THIRDSITE,"").then((res) => {
				var result=res.data;
				if(result.code =="SUCCESS"){
				  this.useldylsit = result.data.list;
				}else{
				  this.$message.error(result.message,3);
				}
			})
		}
	},

	resetldForm(){
		//落地页重置
		this.form8.resetldForm();
	},

	serachldy(e){
		this.form8.validateFieldsAndScroll((err, values) => {
			if(!err){
				var paremsdata = [];
				if(values['name'] !=undefined){
					var numReg = /^[0-9]*$/
					var numRe = new RegExp(numReg)
					if (!numRe.test(values['name'])) {
						paremsdata.push({"siteId":values['name']})
					}else{
						paremsdata.push({"search":values['name']})
					}
				}
			}

			var parems = {"filtering":paremsdata};
			if(values['lanpage'] ==2){
				// 第三方落地页
				ajaxrequest(advertiser_id, THIRDSITE,parems).then((res) => {
					var result=res.data;
					if(result.code =="SUCCESS"){
					  this.useldylsit = result.data.list;
					}else{
					  this.$message.error(result.message,3);
					}
				})
			}else{
				// 橙子建站落地页
				ajaxrequest(advertiser_id, SITEURL,parems).then((res) => {
					var result=res.data;
					if(result.code =="SUCCESS"){
					  this.useldylsit = result.data.list;
					}else{
					  this.$message.error(result.message,3);
					}
				})
			}
			
		})

		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		if(e ==1){
			// 橙子建站落地页
			ajaxrequest(advertiser_id, SITEURL,"").then((res) => {
				var result=res.data;
				if(result.code =="SUCCESS"){
				  this.useldylsit = result.data.list;
				}else{
				  this.$message.error(result.message,3);
				}
			})
		}else{
			// 第三方落地页
			ajaxrequest(advertiser_id, THIRDSITE,"").then((res) => {
				var result=res.data;
				if(result.code =="SUCCESS"){
				  this.useldylsit = result.data.list;
				}else{
				  this.$message.error(result.message,3);
				}
			})
		}
	},

	// serachdis(e){
	// 	//下载页模糊查询
	// 	console.log(e);
	// },

	onuse(item){
		//选择已有
		item = Object.assign({},item, {url:'https://www.chengzijianzhan.com/tetris/page/'+item.siteId+'/'});
		this.externalurl = item;
		this.visibleld = false;
	},
	ldyCancel(){
		this.visibleld = false;
	},

	newregexp(str){
		return new RegExp(str,"g");
	},

	onaddname(n){
		//添加名称
		var reg = '';
		if(n ==1){
			if(this.namelist.indexOf(1) ==-1){
				this.namelist.push(1);
				if(this.name.includes('{定向包名称}')){
					reg = this.newregexp("{定向包名称}","g");
					this.name=this.name.replace(reg,""); 
				}else{
					this.name = this.name+'{定向包名称}';
				}
			}else{
				this.namelist.splice(this.namelist.indexOf(1),1);
				reg = this.newregexp("{定向包名称}","g");
				this.name=this.name.replace(reg,""); 
			}
		}else if(n ==2){
			if(this.namelist.indexOf(2) ==-1){
				this.namelist.push(2);
				if(this.name.includes('{转化名称}')){
					reg = this.newregexp("{转化名称}","g");
					this.name=this.name.replace(reg,""); 
				}else{
					this.name = this.name+'{转化名称}';
				}
			}else{
				this.namelist.splice(this.namelist.indexOf(2),1);
				reg = this.newregexp("{转化名称}","g");
				this.name=this.name.replace(reg,""); 
			}
		}else if(n ==3){
			if(this.namelist.indexOf(3) ==-1){
				this.namelist.push(3);
				if(this.name.includes('{创意组名称}')){
					reg = this.newregexp("{创意组名称}","g");
					this.name=this.name.replace(reg,""); 
				}else{
					this.name = this.name+'{创意组名称}';
				}
			}else{
				this.namelist.splice(this.namelist.indexOf(3),1);
				reg = this.newregexp("{创意组名称}","g");
				this.name=this.name.replace(reg,""); 
			}
		}else if(n ==4){
			if(this.namelist.indexOf(4) ==-1){
				this.namelist.push(4);
				if(this.name.includes('{序号}')){
					reg = this.newregexp("{序号}","g");
					this.name=this.name.replace(reg,""); 
				}else{
					this.name = this.name+'{序号}';
				}
			}else{
				this.namelist.splice(this.namelist.indexOf(4),1);
				reg = this.newregexp("{序号}","g");
				this.name=this.name.replace(reg,""); 
			}
		}
		this.form.setFieldsValue({
			name:this.name,
		})
		this.$forceUpdate(); 
		// console.log(this.name);
	},
	onadname(e){
		this.name = e.target.value;
		if(!this.name.includes('{定向包名称}')){
			this.namelist.splice(this.namelist.indexOf(1),1);
			this.name=this.name.replace("{定向包名称}",""); 
		}
		if(!this.name.includes('{转化名称}')){

			this.namelist.splice(this.namelist.indexOf(2),1);
			this.name=this.name.replace("{转化名称}",""); 
		}
		if(!this.name.includes('{创意组名称}')){
			this.namelist.splice(this.namelist.indexOf(3),1);
			this.name=this.name.replace("{创意组名称}",""); 
		}
		if(!this.name.includes('{序号}')){
			this.namelist.splice(this.namelist.indexOf(4),1);
			this.name=this.name.replace("{序号}",""); 
		}
		this.form.setFieldsValue({
			name:this.name,
		})
		// this.names = this.name;
		this.$forceUpdate();  
	},

	// ondelname(e){
	// 	console.log(e);
	// },
	callback(key){
		// 定向切换
		console.log(key);
  },
  onrangetype(e){
	this.rangetype = e.target.value;
  },
  onback(){
	// 取消
	this.visible = true;
  },
  handleOk(){
	// 取消框确认按钮
	this.$router.go(-2);//返回上二层
	window.localStorage.removeItem("one");
	window.localStorage.removeItem("two");
	window.localStorage.removeItem("three");
	this.visible = false;
  },
  handleCancel(){
	//取消框的取消按钮
	this.visible = false;
  },
  ongoback(){
	// 返回上一步
	window.localStorage.removeItem("one");
	window.localStorage.removeItem("two");
	window.localStorage.removeItem("three");
	this.$router.go(-1);//返回上一层
  },
  onchecktion(){
	// 点击定向包列表
	this.checkloading = true;
	this.loadinglist = true;
	// 选择定向包
	// var type ='';
	// if(this.landinginfo =='APP'){
	// 	type = this.rangetype;
	// }else{
	// 	type = this.landinginfo;
	// }
	var parems = [];
	// parems.push({"field":"landing_type","operator":"EQUALS","value":type});
	// parems.push({"field":"delivery_range","operator":"EQUALS","value":this.delivery_range});
	if(this.newdislist.length >0){
		parems.push({"field":"id","operator":"NOT_IN","value":this.newdislist});
	}
	var convert = {"filtering":parems};
	ajaxparems(PACKAGELIST, convert).then((res) => {
		var result = res.data;
		if (result.code == "SUCCESS") {
			this.checkdstion = true;
			this.checkloading = false;
			this.loadinglist = false;
			this.audiencecheck = false;
			this.dstionlist = result.data.list;
		} else {
			// this.checkdstion = true;
			this.checkloading = false;
			this.loadinglist = false;
			this.$message.error(result.message, 3);
		}
	});
  },
  resetForm(){
	//定向包重置
	this.form3.resetFields();
  },
  serachdis(){
	//查询定向
	this.form3.validateFieldsAndScroll((err, values) => {
		if(!err){
			var parems = [];
			// var dtime = {}
			var time = [];
			if(values['datatime'] =='3'){
				time = this.fun_date(-3);
				parems.push({'field':'created_at',"operator":"LESS_EQUALS","value":time['currenttime']});
				parems.push({'field':'created_at',"operator":"GREATER_EQUALS","value":time['beforetime']});
			}else if(values['datatime'] =='7'){
				time = this.fun_date(-7);
				parems.push({'field':'created_at',"operator":"LESS_EQUALS","value":time['currenttime']});
				parems.push({'field':'created_at',"operator":"GREATER_EQUALS","value":time['beforetime']});
			}else if(values['datatime'] =='15'){
				time = this.fun_date(-15);
				parems.push({'field':'created_at',"operator":"LESS_EQUALS","value":time['currenttime']});
				parems.push({'field':'created_at',"operator":"GREATER_EQUALS","value":time['beforetime']});
			}else if(values['datatime'] =='30'){
				time = this.fun_date(-30);
				parems.push({'field':'created_at',"operator":"LESS_EQUALS","value":time['currenttime']});
				parems.push({'field':'created_at',"operator":"GREATER_EQUALS","value":time['beforetime']});
			}
			if(values['name'] !=undefined){
				parems.push({'field':'name',"operator":"LIKE","value":values['name']});
			}
			if(this.newdislist.length >0){
				parems.push({'field':'id',"operator":"NOT_IN","value":this.newdislist})
			}
			var convert = {"filtering":parems}
			ajaxparems(PACKAGELIST, convert).then((res) => {
				var result = res.data;
				if (result.code == "SUCCESS") {
					this.dstionlist = result.data.list;
				} else {
					this.$message.error(result.message, 3);
				}
			});
		}
	})
  },
	fun_date(aa){
		var timelist = [];
		var date1 = new Date(),
		time1=date1.getFullYear()+"-"+(date1.getMonth()+1)+"-"+date1.getDate();//time1表示当前时间
		var date2 = new Date(date1);
		date2.setDate(date1.getDate()+aa);
		var time2 = date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();
		timelist['currenttime'] = time1;
		timelist['beforetime'] = time2;
		return timelist;
	},
//   onaudience(v){
//   // 选择定向包

//   	if(this.newdislist.indexOf(v.target.value) !== -1){
// 		this.disidslist.splice(this.disidslist.indexOf(v.target.value),1);
// 		this.newdislist.splice(this.newdislist.indexOf(v.target.value),1);
// 	}else{
// 		this.newdislist.push(v.target.value);
// 		this.disidslist.push(v.target.value);
// 	}
// 	this.newdislist.includes(v.target.value)

// 	// console.log(this.newdislist);
//   },
  checkdstionOk(){
	  this.confirmLoading = true;
  // 定向包选中确定框
    if(this.scene ==3){
      if(this.newdislist.length + this.audiencelist.length >=50){
        this.$message.error('超出定向数量限制,数量每次最多为：50');
		this.confirmLoading = false;
        return;
      }
    }else{
      if(this.newdislist.length + this.audiencelist.length >1){
        this.$message.error('超出定向数量限制,数量每次最多为：1');
		this.confirmLoading = false;
        return;
      }
	}

	this.formaudience.validateFieldsAndScroll((err, values) => {
		if(!err){

			// console.log(values['audience_id']);
			if(values['audience_id'].length !=0){
				var convert = {"filtering":[{'field':'id',"operator":"IN","value":values['audience_id']}]}
				ajaxparems(PACKAGELIST, convert).then((res) => {
					var result = res.data;
					if (result.code == "SUCCESS") {
						result.data.list.forEach((res) =>{
							if(this.audiencelist.indexOf(res) ===-1){
								this.audiencelist.push({
									"admin_id":res.admin_id,
									"audience":res.audience,
									"created_at":res.created_at,
									"delivery_range":res.delivery_range,
									"description":res.description,
									"estimate":res.estimate,
									"id":res.id,
									"landing_type":res.landing_type,
									"name":res.name,
									"updated_at":res.updated_at,
								});
								this.newdislist.push(res.id);
							}
						})
						// this.audiencelist = result.data.list;
						this.confirmLoading = false;
					} else {
						this.$message.error(result.message, 3);
					}
				});
			}
		}else{
			this.$message.error('请选择定向包');
		}
	})

	// console.log(this.newdislist);

	// if(this.newdislist.length >0){
	// 	var convert = {"filtering":[{'field':'id',"operator":"IN","value":this.newdislist}]}
	// 	ajaxparems(PACKAGELIST, convert).then((res) => {
	// 		var result = res.data;
	// 		// console.log(result.data.list);
	// 		if (result.code == "SUCCESS") {

	// 			result.data.list.forEach((res) =>{
	// 				console.log(res);
	// 				// this.disidslist.push(res.id);
	// 				this.audiencelist.push({
	// 					"admin_id":res.admin_id,
	// 					"audience":res.audience,
	// 					"created_at":res.created_at,
	// 					"delivery_range":res.delivery_range,
	// 					"description":res.description,
	// 					"estimate":res.estimate,
	// 					"id":res.id,
	// 					"landing_type":res.landing_type,
	// 					"name":res.name,
	// 					"updated_at":res.updated_at,
	// 				});
	// 				// this.newdislist.splice(this.newdislist.indexOf(res.id),1);
	// 			})
	// 			this.confirmLoading = false;
	// 			// this.newdislist = [];
	// 		} else {
	// 			this.$message.error(result.message, 3);
	// 		}
	// 	});
	// }else{
	// 	this.confirmLoading = false;
	// }

	// this.form4.validateFieldsAndScroll(async (err, values) => {
	// 	if(!err){
	// 		console.log(values);
	// 	}
	// })

	// // console.log(this.newdislist);
	// this.newdislist.forEach((res)=>{
	// 	this.disidslist.push(res.id);
	// 	this.audiencelist.push(res);
	// })

	this.checkdstion = false;
  },
  checkdstionCancel(){
	  this.audiencecheck = false;
	// 定向包取消选中框
	this.checkdstion = false;
  },

  adddstion(){
	// 新建定向
	this.dstion = true;
  },
  	dstionCancel(){
	//取消新建定向包model
		this.dstion = false;
	},
	dstionOk(){
		// 保存定向
		this.confirmLoading = true;
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var e = this.disid -1;
		var listnew = {};
		var action_scene = '';

		// 确定新建定向
		this.form2.validateFieldsAndScroll(async (err, values) => {
			if(!err){

				//城市
				if(this.district =='CITY'){
					if(this.citylist.length >0){
						values['city'] = this.citylist;
					}
				}else if(this.district =='COUNTY'){
					if(this.countylist.length >0){
						values['city'] = this.countylist;
					}
				}
				//年龄
				var age = [];
				if(this.agearr.length >0){
					if(this.label.label1 ==true){
						age.push('AGE_BETWEEN_18_23');
					}
					if(this.label.label2 ==true){
						age.push('AGE_BETWEEN_24_30');
					}
					if(this.label.label3 ==true){
						age.push('AGE_BETWEEN_31_40');
					}
					if(this.label.label4 ==true){
						age.push('AGE_BETWEEN_41_49');
					}
					if(this.label.label5 ==true){
						age.push('AGE_ABOVE_50');
					}
				}
				values['age'] = age;
				
				//平台
				var platform = [];
				if(this.platform.length >0){
					if(this.label.android ==true){
						platform.push('ANDROID');
					}
					if(this.label.iOS ==true){
						platform.push('IOS');
					}
					if(this.label.PC ==true){
						platform.push('PC');
					
					}
				}
				values["platform"] = platform;
				//网络
				var ac = [];
				if(this.networks.length >0){
					if(this.label.wifi == true){
						ac.push('WIFI');
					}
					if(this.label.twog == true){
						ac.push('2G');
					}
					if(this.label.threeg == true){
						ac.push('3G');
					}
					if(this.label.forg == true){
						ac.push('4G');
					}
				}
				values["ac"] = ac;
				//运营商
				var carrier = [];
				if(this.operator.length >0 ){
					if(this.label.MOBILE == true){
						carrier.push('MOBILE');
					}
					if(this.label.UNICOM == true){
						carrier.push('UNICOM');
					}
					if(this.label.TELCOM == true){
						carrier.push('TELCOM');
					}
				}
				values['carrier'] = carrier;

				// 新用户
				var activate_type = [];
				if(this.monthlist.length > 0){
					if(this.label.WITH_IN_A_MONTH == true){
						activate_type.push('WITH_IN_A_MONTH');
					}
					if(this.label.ONE_MONTH_2_THREE_MONTH == true){
						activate_type.push('ONE_MONTH_2_THREE_MONTH');
					}
					if(this.label.THREE_MONTH_EAILIER == true){
						activate_type.push('SIX_MTHREE_MONTH_EAILIERONTH');
					}
				}
				values['activate_type'] = activate_type;
				//文章分类
				var article_category = [];
				if(this.rowarticlelist.length >0){
					this.rowarticlelist.forEach((reslist)=>{
						article_category.push(reslist.value);
					})
				}
				values['article_category'] = article_category;
					//手机品牌
					var device_brand = [];
				if(this.rowbrandlist.length >0){
					this.rowbrandlist.forEach((reslist)=>{
						device_brand.push(reslist.value);
					})
				}
				values['device_brand'] = device_brand;
				// 手机价格
				if(this.strnum !=''){
					values['strnum'] = this.strnum[0];
				}

				action_scene = values['action_scene'];

				//智能放量
				var listauto = [];
				if(this.rowenabledlist.length >0){
					listauto = this.rowenabledlist;
				}
				values['rowenabledlist'] = listauto;
				var aData = new Date();
				let hh = aData.getHours();
				let mf = aData.getMinutes()<10 ? '0'+aData.getMinutes() : aData.getMinutes();
				let ss = aData.getSeconds()<10 ? '0'+aData.getSeconds() : aData.getSeconds();

				listnew['created_at'] =  aData.getFullYear() + "-" + (aData.getMonth() + 1) + "-" + aData.getDate() +' '+hh+':'+mf+':'+ss;
				var type = "";
				if(this.landinginfo =='APP'){
					type = this.rangetype;
				}else{
					type = this.landinginfo;
				}
				var audienceone = '';
				values["landing_type"] = type;
				// 定向人群
				if(this.selectedRows.length >0){
					values['retargeting_tags'] = this.selectedRows;
				}
				//排除人群
				if(this.selectedRowss.length >0){
					values['retargeting_tags_exclude'] = this.selectedRowss;
				}

				// 行为类目词
				if(this.catewords.length >0){
					values['action_categories'] = this.catewords;
				}
				//行为关键词
				if(this.datakeyword.length >0){
					values['action_words'] = this.datakeyword;
				}

				// 兴趣类目词
				if(this.catewordslist.length >0){
					values['interest_categories'] = this.catewordslist;
				}
				//兴趣关键词
				if(this.datakey.length >0){
					values['interest_words'] = this.datakey;
				}

				// 抖音达人
				if(this.rowtiktoktalentlist.length >0){
					values['aweme_fan_categories'] = this.rowtiktoktalentlist;
				}

				//媒体定向
				if(this.rowpackagelist.length >0){
					values['flow_package'] = this.rowpackagelist;
				}

				//媒体排除
				if(this.rowpackagelists.length >0){
					values['exclude_flow_package'] = this.rowpackagelists;
				}


				// console.log(page.list[0].audience_id);

				if(values['istemp'] !="0"){
					this.$delete(values,'istemp');
					if(page.type ==3){
						this.$delete(values,'action_scene');
						await ajaxrequest(page.list[0].advertiser_id, AUDIENCE,values).then((res) => {
							var resultence = res.data;
							if(resultence.code == "SUCCESS"){
								audienceone = resultence.data;
							}else{
								this.$message.error(resultence.message,3);
								return;
							}
						})
						values['action_scene'] = action_scene;
						values['delivery_range'] = this.delivery_range;
						listnew['name'] = values['name'];
						listnew['audience'] = values;
						listnew['estimate'] = audienceone;
						ajaxparems(ADDPACKAGE, listnew).then((res) => {
							var result = res.data;
							if (result.code == "SUCCESS") {
								console.log('成功');
							} else {
								this.$message.error(result.message, 3);
								return;
							}
						});
						
						if(this.disid !='' || this.disid !=0){
							this.audiencelist[e] = listnew;
							this.$message.success("编辑定向包成功");
							this.disid = '';
						}else{
							this.audiencelist.push(listnew);
							this.$message.success("新建定向包成功");
							this.disid = '';
						}
						this.dstion =false;
					}else{
						await ajaxrequest(page.advertiser_id, AUDIENCE,values).then((res) => {
							var resultence = res.data;
							if(resultence.code == "SUCCESS"){
								audienceone = resultence.data;
							}else{
								this.$message.error(resultence.message,3);
								return;
							}
						})
						values['delivery_range'] = this.delivery_range;
						listnew['name'] = values['name'];
						listnew['audience'] = values;
						listnew['estimate'] = audienceone;
						ajaxparems(ADDPACKAGE, listnew).then((res) => {
							var result = res.data;
							if (result.code == "SUCCESS") {
								console.log('成功');
							} else {
								this.$message.error(result.message, 3);
								return;
							}
						});
						if(this.disid !='' || this.disid !=0){
							this.audiencelist[e] = listnew;
							this.$message.success("编辑定向包成功");
							this.disid = '';
						}else{
							this.audiencelist.push(listnew);
							this.$message.success("新建定向包成功");
							this.disid = '';
						}
						this.dstion =false;
					}
				}else{
					if(page.type ==3){
						this.$delete(values,'action_scene');
						await ajaxrequest(page.list[0].advertiser_id, AUDIENCE,values).then((res) => {
							var resultence = res.data;
							if(resultence.code == "SUCCESS"){
								audienceone = resultence.data;
							}else{
								this.$message.error(resultence.message,3);
							}
							listnew['name'] = values['name'];
							listnew['audience'] = values;
							listnew['estimate'] = audienceone;
						})
					}else{
						this.$delete(values,'action_scene');
						await ajaxrequest(page.advertiser_id, AUDIENCE,values).then((res) => {
							var resultence = res.data;
							if(resultence.code == "SUCCESS"){
								audienceone = resultence.data;
							}else{
								this.$message.error(resultence.message,3);
							}
						})
						listnew['name'] = values['name'];
						listnew['audience'] = values;
						listnew['estimate'] = audienceone;
					}

					if(this.disid !=''){
						this.audiencelist[e] = listnew;
						this.$message.success("编辑定向包成功");
						this.disid = '';
					}else{
						this.audiencelist.push(listnew);
						this.$message.success("新建定向包成功");
						this.disid = '';
					}
					this.dstion = false;
				}
				this.confirmLoading = false;
				// console.log(this.audiencelist);
			}else{
				this.confirmLoading = false;
			}
		})
	},
	editdis(e){
		// 编辑定向
		var info =this.audiencelist[e];
		console.log(info);
		//省市
		if(info.audience.district =="CITY"){
			this.treeData = info.audience.treeData
		}
		//年龄
		this.agearr = info.audience.age;
		if(info.audience.retargeting_tags_include !=undefined){
			this.selectedRows = info.audience.retargeting_tags_include;//人群定向数组
		}
		if(info.audience.retargeting_tags_exclude !=undefined){
			this.selectedRowss = info.audience.retargeting_tags_exclude;//人群排除数组
		}
		if(info.audience.aweme_fan_behaviors !==undefined && info.audience.aweme_fan_behaviors.length >'0'){
            this.form2.setFieldsValue({
              aa:"RECOMMEND",
            })
            this.tiktok = "RECOMMEND";
        }else{
            this.form2.setFieldsValue({
              aa:"NONE",
            })
        }
		this.rowcategorieslist = info.audience.aweme_fan_behaviors;//抖音达人分类
		if(info.audience.retargeting_tags_include !==undefined && info.audience.retargeting_tags_include.length >'0'){
            this.retargeting_tags = "retargeting_tags_include";
        }
        if(info.audience.retargeting_tags_exclude !==undefined && info.audience.retargeting_tags_exclude.length >'0'){
            this.retargeting_tags = "retargeting_tags_exclude";
        }
        if(info.audience.aweme_fan_behaviors !==undefined && info.audience.aweme_fan_behaviors.length >'0'){
            this.form2.setFieldsValue({
              aweme_fan_behaviors:info.audience.aweme_fan_behaviors,//抖音达人
            })
		}
		//行为兴趣
		if(info.audience.superior_popularity_type =="RECOMMEND"){
            this.superior="RECOMMEND";
        }
        //  自定义人群包
        if(info.audience.flow_package !==undefined && info.audience.flow_package.length >'0'){
            this.packages = "flow_package";
            this.rowpackagelist = info.audience.flow_package;
        }else if(info.audience.exclude_flow_package !==undefined && info.audience.exclude_flow_package.length>'0'){
            this.packages = "exclude_flow_package";
            this.rowpackagelists = info.audience.exclude_flow_package;
        }
        this.platform = info.audience.platform;//平台
        this.networks = info.audience.ac;//网络
        //过滤转化用户
        if(info.audience.hide_if_converted =="APP" || info.audience.hide_if_converted =="CUSTOMER"){
            this.isconverted = true;
        }
        //文章分类
        if(info.audience.article_category !==undefined && info.audience.article_category.length >'0'){
            this.form2.setFieldsValue({
              wenzhang:1,
            })
            this.article = 1;
            this.rowarticlelist = info.audience.article_category;
        }
        //运营商
        this.operator = info.audience.carrier;
        this.monthlist = info.audience.activate_type;//新用户
        // //手机品牌
        if(info.audience.device_brand !==undefined && info.audience.device_brand.length >'0'){
            this.form2.setFieldsValue({
              pinpai:1,
            })
            this.brand = 1;
            this.rowbrandlist = info.audience.device_brand;
        }
        // //价格
        if(info.audience.launch_price !==undefined && info.audience.launch_price.length >'0'){
            this.form2.setFieldsValue({
              jiage:1,
            })
            this.launchprice = 1;
            this.pricearr = info.audience.launch_price;
        }
          // this.rowenabledlist = info.audience.audience.auto_extend_targets;
        // this.sceneselect = info.audience.smart_bid_type;//放量
        // this.schedule_type = info.audience.schedule_type;
        // this.adjust = info.audience.flow_control_mode;
		this.form2.setFieldsValue({
			name:info.name,
			description:info.audience.description,
			district:info.audience.district,
			location_type:info.audience.location_type,
			gender:info.audience.gender,
			retargetings:info.audience.retargetings,
			interest_action_mode:info.audience.interest_action_mode,
			action_scene:info.audience.action_scene,
			action_days:info.audience.action_days,
			aa:info.audience.aa,
			aweme_fan_behaviors:info.audience.aweme_fan_behaviors,
			superior_popularity_type:info.audience.superior_popularity_type,
			filter_aweme_abnormal_active:info.audience.filter_aweme_abnormal_active,
			filter_own_aweme_fans:info.audience.filter_own_aweme_fans,
			filter_aweme_fans_count:info.audience.filter_aweme_fans_count,
			hide_if_exists:info.audience.hide_if_exists,
			hide_if_converted:info.audience.hide_if_converted,
			activate_type:info.audience.activate_type,
			auto_extend_enabled:info.audience.auto_extend_enabled,
		})

		this.dstion = true;
		this.disid = e+1;
	},
	copydis(e){
		if(this.scene ==3){
			if(this.audiencelist.length >=50){
				return;
			}
			//复制定向
			this.copyvis = true;
			this.copyindex = e;
			if(this.audiencelist[e].name.indexOf("_copy") != -1){
				this.copynames = this.audiencelist[e].name;
			}else{
				this.copynames = this.audiencelist[e].name+'_copy';
			}
		}else{
			return;
		}
	},
	copyCancel(){
		this.copyvis = false;
	},
	oncopyname(e){
		this.copynames = e.target.value;
	},
	copyOk(){
		var e = this.copyindex;
		var name = this.copynames;
		if(name == ''){
			this.$message.error('请输入定向包名称',3);
			return;
		}
		let obj = {}
		for (const key in this.audiencelist[e]) {
			obj[key] = this.audiencelist[e][key]
		}
		this.objlist = obj;
		this.$set(this.objlist,'name',name);
		this.audiencelist.push(
			this.objlist
		);
		this.copyvis = false;
	},

	closedis(e,id){
		//删除指定定向
		console.log(id);
		this.newdislist.splice(this.newdislist.indexOf(id),1)
		console.log(this.newdislist);
		this.audiencelist.splice(this.audiencelist.indexOf(e),1);
	},
  	async pageinfo() {
	// 查询信息
		var storage=window.localStorage;
		var info = storage.getItem("one");
    	var page = JSON.parse(info);
		this.scene = page.scene;
		this.typeinfo = page.type;
		this.landinginfo = page.landing_type;
		this.landing_type = page.landing_type;
		var parems = '';
		var adverparems = '';
		if(page.type ==1){
			parems = {"filtering":[
				{"field":"account_id","operator":"EQUALS","value":page.advertiser_id},
			]};
			await ajaxparems(ACCOUNTURL, parems).then((res) => {
					var result = res.data;
					if (result.code == "SUCCESS") {
					  this.account = result.data;
					} else {
					this.$message.error(result.message, 3);
					}
			});
			this.pagesinfo = page;
			this.tabs = page.tabs;
		}else if(page.type ==2){
		  //查询账号
			parems = {"filtering":[
				{"field":"account_id","operator":"EQUALS","value":page.advertiser_id},
			]};
		  ajaxparems(ACCOUNTURL, parems).then((res) => {
				var result = res.data;
				if (result.code == "SUCCESS") {
				  this.account = result.data;
				} else {
				  this.$message.error(result.message, 3);
				}
		  });
		  //查询多个广告组
		  adverparems = {"filtering":[
			{"field":"id","operator":"IN","value":page.campaignlist},
		  ]};
		  ajaxparems(ADVER, adverparems).then((res) => {
				var result = res.data;
				if (result.code == "SUCCESS") {
				  this.campaignlist = result.data.list;
				} else {
				  this.$message.error(result.message, 3);
				}
		  });
		  this.tabs = page.tabs;
		}else if(page.type ==3){
			//  查询多个账户
			var account = [];
			var campaignlist = [];
			page.list.forEach((res)=>{
				account.push(res.advertiser_id)
				// campaignlist.push(res.campaignlist)
				res.campaignlist.forEach((e)=>{
					campaignlist.push(e);
				})
			})

			parems = {"filtering":[
			{"field":"account_id","operator":"IN","value":account},
			]};
			ajaxparems(ACCOUNTURL, parems).then((res) => {
				var result = res.data;
				if (result.code == "SUCCESS") {
					this.account = result.data;
				} else {
				this.$message.error(result.message, 3);
				}
			});
			this.campaignlist = campaignlist;
			// console.log(campaignlist);

			// adverparems = {"filtering":[
			// 	{"field":"id","operator":"IN","value":campaignlist},
			// ]};
			// ajaxparems(ADVER, adverparems).then((res) => {
			// 	var result = res.data;
			// 	if (result.code == "SUCCESS") {
			// 	this.campaignlist = result.data.list;
			// 	} else {
			// 	this.$message.error(result.message, 3);
			// 	}
			// });

		}
	  // if(page.type ==1){

	  // }
	  // console.log(page);

	  // this.datainfo = info;
  //   var parems = {"filtering":[
  //     {"field":"id","operator":"EQUALS","value":this.ids},
  //     ]};
  //     ajaxparems(ADVER, parems).then((res) => {
  //       var result = res.data;
  //       if (result.code == "SUCCESS") {
  //       this.datalist = result.data.list[0];
  //       // this.landing_type = result.data.list[0].landing_type;
  //       } else {
  //         this.$message.error(result.message, 3);
  //       }
  //     });
  //   this.updatename();
    this.listNew();
	this.onestimate();
  },
  //点击省
  onprovince(e){
	var cityparems = {"parent_id":e};
	ajaxparems(CITYGET,cityparems).then((res) => {
		var result = res.data;
		if(result.code =="SUCCESS"){
			this.city = result.data;
			this.county = [];
		}else{
			this.$message.error(result.message,3);
		}
	});
},

//点击市
oncity(e){
	this.is_checkedcity = false;
	var cityparems = {"parent_id":e};
	ajaxparems(CITYGET,cityparems).then((res) => {
		var result = res.data;
		console.log(result);
		if(result.code =="SUCCESS"){
			this.county = result.data;
		}else{
			this.$message.error(result.message,3);
		}
	});
},

//删除已选区县
oncountydel(id){
	// this.countylist
	this.countylist.splice(this.countylist.findIndex(v => id == v.id),1);
},
onallchecked(e){
	console.log(e.target.checked);
	//区县全选
	if(e.target.checked == true){
		this.is_checkedcity = true;
		this.checkedcitytrue(this.county);
	}else{
		this.is_checkedcity = false;
		this.checkedcityfalse(this.county);
	}
	this.autoaudience();
},

checkedcitytrue(arr){
	//确定区县全选
	if(arr.length <= 0){
		return;
	}
	arr.map(v=>{
		v.is_checked = true				
	});
	arr.forEach((item) =>{
		this.countylist.push(item);
	})
},

checkedcityfalse(arr){
	//取消区县全选
	if(arr.length <= 0){
		return;
	}
	arr.map(v=>{
		v.is_checked = false
		this.countylist.splice(this.countylist.indexOf(v),1)
	});
},
oncountyoff(n,id){
	var current = this.county[n];
	if(current.is_checked == true){
		this.county[n].is_checked = false;
		this.countylist.splice(this.countylist.findIndex(v => id == v.id),1);
	}else{
		this.county[n].is_checked = true;
		this.countylist.push(current);
	}
	this.autoaudience();
},

  onexternal(value){
    //监听下载落地页输入框
    if(value !=''){
      this.external= false;
    }else{
      this.external= true;
    }
  },
  onconversion(){
    // 获取转化目标
    if(this.track == false){
      this.track = true;
    }else{
      this.track = false;
	}
	
	var storage=window.localStorage;
	var info = storage.getItem("one");
	var page = JSON.parse(info);
    var convert = {};
    if(page.type ==3){
      	convert = {"filtering":[{"field":'account_id',"operator":'EQUALS',"value":page.advertiser_id[0]}]};
    }else{
		convert = {"filtering":[{"field":'account_id',"operator":'EQUALS',"value":page.advertiser_id}]};
    }
    //转化目标
    ajaxparems(ADCONVERT,convert).then((res) => {
          var result = res.data;
          if(result.code =="SUCCESS"){
          this.radiolist = result.data;
        }else{
          this.$message.error(result.message,3);
        }
    });
  },
  onconversions(){
      // // 获取转化目标
      if(this.tracks == false){
        this.tracks = true;
      }else{
        this.tracks = false;
	  }
	  var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var convert = {};
		if(page.type ==3){
			convert = {"filtering":[{"field":'account_id',"operator":'EQUALS',"value":page.advertiser_id[0]}]};
		}else{
			convert = {"filtering":[{"field":'account_id',"operator":'EQUALS',"value":page.advertiser_id}]};
		}
      //转化目标
      ajaxparems(ADCONVERT,convert).then((res) => {
        var result = res.data;
        if(result.code =="SUCCESS"){
          this.radiolist = result.data;
        }else{
          this.$message.error(result.message,3);
        }
      });
  },
  // onappline(v){
  //   //筛选转化目标
  //   var convert = {"advertiser_id":'1657869217074189'};
  //   ajaxrequest("1657869217074189", ADCONVERT,convert).then((res) => {
  //       var convertlist=res.data;
  //       if(convertlist.code =="SUCCESS"){
  //           convertlist.data.ad_convert_list.forEach(function(item) {
  //             radiolist.push(item);
  //           });
  //       }else{
  //         this.$message.error(convertlist.message,3);
  //       }
  //   })
  // },
    onovers(){
      // 鼠标经过事件
      console.log(1);
      // console.log(v);
    },
    onSearch(value) {
      // 搜索
      var parems = {"filtering":[
        {"field":"id","operator":"EQUALS","value":value},
        {"field":"name","operator":"LIKE","value":value},
        ]};
      ajaxparems(ADVER, parems).then((res) => {
        var result = res.data;
        this.datalist = result.data.list;
      });
    },
    onrange(e){
      // 投放范围
      this.delivery_range = e.target.value;
    },
    onunion(e){
	  // 投放形式
      this.union_video_type = e.target.value;
	},
	onpricing(e){
		// 投放目标
    this.pricings = e.target.value;
    this.updatename();
	},
	ondownload(e){
		// 下载落地页
		this.download_type = e.target.value;
  },
  choicetiktok(){
	// 选择抖音号
	var storage=window.localStorage;
	var info = storage.getItem("one");
	var page = JSON.parse(info);
    var advertiser_id = '';
    if(page.type ==3){
		advertiser_id= page.list[0].advertiser_id;
    }else{
		advertiser_id = page.advertiser_id;
    }
    ajaxrequest(advertiser_id, IESACCOUNT, "").then((res) => {
      var result = res.data;
      if(result.code =="SUCCESS"){
        this.tiktoklist = result.data;
      }else{
        this.$message.error(result.message,3);
      }
    });
    if(this.tiktokbox ==false){
      this.tiktokbox = true;
    }else{
      this.tiktokbox = false;
    }
  },
  onexternaltype(){
    // 转化类型
    if(this.externaltype ==false){
      this.externaltype = true;
    }else{
      this.externaltype = false;
    }
  },
  onpromotion(e){
    //抖音投放内容
    this.promotion_type = e.target.value;
  },
  onopenurl(e){
    this.openurl = e.target.value;
  },
	ondistrict(e){
		//地域
		this.district = e.target.value;

		if(e.target.value =="NONE"){
			this.citylist = [];
			this.countylist = [];
			this.county = [];
		}
		this.autoaudience();
	},
	ongender(e){
		//性别
		this.gender = e.target.value;
		this.autoaudience();
  },
  onlabel(){
    this.agearr = [];
    this.label.label1 = false;
    this.label.label2 = false;
    this.label.label3 = false;
    this.label.label4 = false;
	this.label.label5 = false;
	this.autoaudience();
  },
	label1(){
		var check = this.label.label1;
		if(check){
			this.agearr.splice(this.agearr.indexOf(1),1)
			this.label.label1 = false;
		}else{
			this.agearr.push(1);
			this.label.label1 = true;
		}
		this.autoaudience();
	},
	label2(){
		var check = this.label.label2;
		if(check){
			this.agearr.splice(this.agearr.indexOf(2),1)
			this.label.label2 = false;
		}else{
			this.agearr.push(2);
			this.label.label2 = true;
		}
		this.autoaudience();
	},
	label3(){
		var check = this.label.label3;
		if(check){
			this.agearr.splice(this.agearr.indexOf(3),1)
			this.label.label3 = false;
		}else{
			this.agearr.push(3);
			this.label.label3 = true;
		}
		this.autoaudience();
	},
	label4(){
		var check = this.label.label4;
		if(check){
			this.agearr.splice(this.agearr.indexOf(4),1)
			this.label.label4 = false;
		}else{
			this.agearr.push(4);
			this.label.label4 = true;
		}
		this.autoaudience();
	},
	label5(){
		var check = this.label.label5;
		if(check){
			this.agearr.splice(this.agearr.indexOf(5),1)
			this.label.label5 = false;
		}else{
			this.agearr.push(5);
			this.label.label5 = true;
		}
		this.autoaudience();
    },
    onplatform(){
      this.platform = [];
      this.label.android = false;
      this.label.iOS = false;
      this.label.PC = false;
	  this.autoaudience();
    },
    android(){
        var check = this.label.android;
		if(check){
			this.platform.splice(this.platform.indexOf(1),1)
			this.label.android = false;
		}else{
			this.platform.push(1);
			this.label.android = true;
		}
		this.autoaudience();
    },
    iOS(){
        var check = this.label.iOS;
		if(check){
			this.platform.splice(this.platform.indexOf(2),1)
			this.label.iOS = false;
		}else{
			this.platform.push(2);
			this.label.iOS = true;
		}
		this.autoaudience();
    },
    PC(){
        var check = this.label.PC;
		if(check){
			this.platform.splice(this.platform.indexOf(3),1)
			this.label.PC = false;
		}else{
			this.platform.push(3);
			this.label.PC = true;
		}
		this.autoaudience();
    },
    onnetworks(){
      this.networks = [];
      this.label.wifi = false;
      this.label.twog = false;
      this.label.threeg = false;
      this.label.forg = false;
	  this.autoaudience();
    },
    wifi(){
        var check = this.label.wifi;
		if(check){
			this.networks.splice(this.networks.indexOf(1),1)
			this.label.wifi = false;
		}else{
			this.networks.push(1);
			this.label.wifi = true;
		}
		this.autoaudience();
    },
    twog(){
        var check = this.label.twog;
		if(check){
			this.networks.splice(this.networks.indexOf(2),1)
			this.label.twog = false;
		}else{
			this.networks.push(2);
			this.label.twog = true;
		}
		this.autoaudience();
    },
    threeg(){
        var check = this.label.threeg;
		if(check){
			this.networks.splice(this.networks.indexOf(3),1)
			this.label.threeg = false;
		}else{
			this.networks.push(3);
			this.label.threeg = true;
		}
		this.autoaudience();
    },
    forg(){
        var check = this.label.forg;
      if(check){
        this.networks.splice(this.networks.indexOf(4),1)
        this.label.forg = false;
      }else{
        this.networks.push(4);
        this.label.forg = true;
	  }
	  this.autoaudience();
    },
    onnone(){
      this.operator= [];
    },
    onoperator(){
      this.operator = [];
      this.label.MOBILE =false;
      this.label.UNICOM =false;
      this.label.TELCOM =false;
	  this.autoaudience();
    },
    MOBILE(){
      var check = this.label.MOBILE;
      if(check){
        this.operator.splice(this.operator.indexOf('MOBILE'),1)
        this.label.MOBILE = false;
      }else{
        this.operator.push('MOBILE');
        this.label.MOBILE = true;
	  }
	  this.autoaudience();
    },
    UNICOM(){
      var check = this.label.UNICOM;
      if(check){
        this.operator.splice(this.operator.indexOf('UNICOM'),1)
        this.label.UNICOM	 = false;
      }else{
        this.operator.push('UNICOM');
        this.label.UNICOM	 = true;
	  }
	  this.autoaudience();
    },
    TELCOM(){
      var check = this.label.TELCOM;
      if(check){
        this.operator.splice(this.operator.indexOf('TELCOM'),1)
        this.label.TELCOM	 = false;
      }else{
        this.operator.push('TELCOM');
        this.label.TELCOM	 = true;
	  }
	  this.autoaudience();
    },
    onmonthlist(){
      this.monthlist = [];
      this.label.WITH_IN_A_MONTH = false;
      this.label.ONE_MONTH_2_THREE_MONTH = false;
      this.label.THREE_MONTH_EAILIER = false;
	  this.autoaudience();
    },
    WITH_IN_A_MONTH(){
      var check = this.label.WITH_IN_A_MONTH;
      if(check){
        this.monthlist.splice(this.monthlist.indexOf('WITH_IN_A_MONTH'),1)
        this.label.WITH_IN_A_MONTH	 = false;
      }else{
        this.monthlist.push('WITH_IN_A_MONTH');
        this.label.WITH_IN_A_MONTH	 = true;
	  }
	  this.autoaudience();
    },
    ONE_MONTH_2_THREE_MONTH(){
      var check = this.label.ONE_MONTH_2_THREE_MONTH;
      if(check){
        this.monthlist.splice(this.monthlist.indexOf('ONE_MONTH_2_THREE_MONTH'),1)
        this.label.ONE_MONTH_2_THREE_MONTH	 = false;
      }else{
        this.monthlist.push('ONE_MONTH_2_THREE_MONTH');
        this.label.ONE_MONTH_2_THREE_MONTH	 = true;
	  }
	  this.autoaudience();
    },
    THREE_MONTH_EAILIER(){
      var check = this.label.THREE_MONTH_EAILIER;
      if(check){
        this.monthlist.splice(this.monthlist.indexOf('THREE_MONTH_EAILIER'),1)
        this.label.THREE_MONTH_EAILIER	 = false;
      }else{
        this.monthlist.push('THREE_MONTH_EAILIER');
        this.label.THREE_MONTH_EAILIER	 = true;
	  }
	  this.autoaudience();
    },
	onretargeting(e){
		// 自定义人群
		this.retargeting = e.target.value;
		if(e.target.value =="NONE"){
			this.selectedRows = [];
			this.selectedRowss = [];
		}
		this.autoaudience();
	},
	onretargetingtags(e){
		// 定向逻辑
		this.retargeting_tags = e.target.value;
		this.autoaudience();
	},
	oninterest(e){
		this.interest = e.target.value;
		this.autoaudience();
	},
	oncategoriesword(value){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
    if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}
        //行为类目词或关键词搜索
		var action_days = this.action_days;
		var action_scene = '';
		if(this.action_scene ==""){
			action_scene = ['E-COMMERCE','NEWS','APP'];
		}else{
			action_scene = [this.action_scene];
		}
		this.keyvalue = value;
		var parems = {};
		console.log(this.action_key);

		// if(this.action_key =="action_categories"){
		// 	//类目词
		// 	parems = {"action_scene":action_scene,'action_days':action_days,"query_words":value};
		// 	ajaxrequest(advertiser_id, KEYWORDSURL,parems).then((res) => {
		// 		var result=res.data;
		// 		if(result.code =="SUCCESS"){
		// 			this.categorieslist = result.data.list;
		// 		}else{
		// 			this.$message.error(result.message,3);
		// 		}
		// 	})
		// }else{
			// 关键词
			parems = {"action_scene":action_scene,'action_days':action_days,"query_words":value};
			ajaxrequest(advertiser_id, KEYWORDSURL,parems).then((res) => {
				var result=res.data;
				if(result.code =="SUCCESS"){
					this.keyswordlist = result.data.list;
					// this.datakeyword = result.data.list;
				}else{
					this.$message.error(result.message,3);
				}
			})
		// }
	},

	oninterestword(value){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
    if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		//兴趣类目词或关键词搜索
		var action_days = this.action_days;
		var action_scene = '';
		if(this.action_scene ==""){
			action_scene = ['E-COMMERCE','NEWS','APP'];
		}else{
			action_scene = [this.action_scene];
		}
		this.interestvalue = value;
		var parems = {};
			// 关键词
			parems = {"action_scene":action_scene,'action_days':action_days,"query_words":value};
			ajaxrequest(advertiser_id, INTERESTKEY,parems).then((res) => {
				var result=res.data;
				if(result.code =="SUCCESS"){
					this.interestkeyword = result.data.list;
				}else{
					this.$message.error(result.message,3);
				}
			})
	},
	addkeys(arr){
		//添加关键词
		this.titleArr.push(arr);
		this.datakeyword.push(arr);
		// this.catewords.push(arr);
	},
	querykeys(v){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
    if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		var action_days = this.action_days;
		var action_scene = '';
		if(this.action_scene ==""){
			action_scene = ['E-COMMERCE','NEWS','APP'];
		}else{
			action_scene = [this.action_scene];
		}
		this.keyvalue = v;
		this.action_key = "action_words";
		var parems = {};
		parems = {"action_scene":action_scene,'action_days':action_days,"query_words":v};
		ajaxrequest(advertiser_id, KEYWORDSURL,parems).then((res) => {
			var result=res.data;
			if(result.code =="SUCCESS"){
				this.keyswordlist = result.data.list;
				// this.datakeyword = result.data.list;
			}else{
				this.$message.error(result.message,3);
			}
		})
	},
	querykeywork(v){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
    if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		var action_days = this.action_days;
		var action_scene = '';
		if(this.action_scene ==""){
			action_scene = ['E-COMMERCE','NEWS','APP'];
		}else{
			action_scene = [this.action_scene];
		}
		this.interestvalue = v;
		this.action_key = "action_words";

		var parems = {};
		parems = {"action_scene":action_scene,'action_days':action_days,"query_words":v};
		ajaxrequest(advertiser_id, KEYWORDSURL,parems).then((res) => {
			var result=res.data;
			if(result.code =="SUCCESS"){
				this.interestkeyword = result.data.list;
				// this.datakeyword = result.data.list;
			}else{
				this.$message.error(result.message,3);
			}
		})
	},
	onwords(v){
		// 删除行为词
		console.log(v);
		this.titleArr.splice(this.titleArr.indexOf(this.titleArr[v]),1);
		// this.catewords.splice(this.catewords.indexOf(this.catewords[v]),1)
		// this.datakeyword.splice(this.datakeyword.indexOf(this.datakeyword[v]),1)

		// this.audiencelist.splice(this.audiencelist.indexOf(e),1);

		// this.cheakedFalse(this.categorieslist,this.arr1CheckedIndex);
		// this.cheakedFalse(this.arr2,this.arr2CheckedIndex);
		// this.cheakedFalse(this.arr3,this.arr3CheckedIndex);
	},
	onkeywords(v){
		//删除类目词
		this.titleArray.splice(this.titleArray.indexOf(this.titleArray[v]),1)
		// this.titleArray.splice(this.titleArray.indexOf(v),1)
		// this.cheakedFalses(this.categorieslist,this.array1CheckedIndex);
		// this.cheakedFalses(this.array2,this.array2CheckedIndex);
		// this.cheakedFalses(this.array3,this.array3CheckedIndex);
	},
	onscene(v){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
    if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		// 行为场景
		var action_days = this.action_days;
		this.action_scene = v;
		var parems = {"action_scene":[v],'action_days':action_days};
		// 行为类目词
        ajaxrequest(advertiser_id, CATEGORYURL,parems).then((res) => {
			var category=res.data;
			if(category.code =="SUCCESS"){
				this.categorieslist = category.data;
			}else{
				this.$message.error(category.message,3);
			}
		})

		// 行为关键词
		var keyvalue = "";
		if(this.keyvalue !=""){
			keyvalue = this.keyvalue;
		}else{
			keyvalue ="";
		}
		var keyparems = {"action_scene":[v],'action_days':action_days,"query_words":keyvalue};
        ajaxrequest(advertiser_id, KEYWORDSURL,keyparems).then((res) => {
			var category=res.data;
			if(category.code =="SUCCESS"){
				this.categorieslist = category.data;
			}else{
				this.$message.error(category.message,3);
			}
		})

		// 兴趣类目词
		ajaxrequest(advertiser_id, INTERESTURL,parems).then((res) => {
			var category=res.data;
			if(category.code =="SUCCESS"){
				this.interestlist = category.data;
			}else{
				this.$message.error(category.message,3);
			}
		})
		
		//兴趣关键词
		var keyvalues = "";
		if(this.keyvalue !=""){
			keyvalues = this.keyvalue;
		}else{
			keyvalues ="";
		}
		var keyparemss = {"action_scene":[v],'action_days':action_days,"query_words":keyvalues};
		ajaxrequest(advertiser_id, INTERESTKEY,keyparemss).then((res) => {
			var category=res.data;
			if(category.code =="SUCCESS"){
				this.interestkeyword = category.data;
			}else{
				this.$message.error(category.message,3);
			}
        })
	},
	ondays(v){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
    if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		//行为天数
		this.action_days = v;
		// var action_scene = this.action_scene;
		var action_scene = '';
		if(this.action_scene ==""){
			action_scene = ['E-COMMERCE','NEWS','APP'];
		}else{
			action_scene = [this.action_scene];
		}
		var parems = {"action_scene":action_scene,'action_days':v};
        ajaxrequest(advertiser_id, CATEGORYURL,parems).then((res) => {
			var category=res.data;
			if(category.code =="SUCCESS"){
				this.categorieslist = category.data;
			}else{
				this.$message.error(category.message,3);
			}
        })
	},
	ontiktok(e){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

        //抖音达人
		this.tiktok = e.target.value;
		if(e.target.value =='RECOMMEND'){
			ajaxrequest(advertiser_id, AWEMELEVEL,"").then((res) => {
				var result=res.data;
				if(result.code =="SUCCESS"){
					var list = [];
					result.data.categories.forEach((res)=>{
						list.push({
							id:res.id,
							value:res.value,
							name:res.value,
							fans_num_str:res.fans_num_str,
							son:res.children
						})
						this.tiktoktalent = list;
					})
					// this.tiktoktalent = result.data.categories;
				}else{
					this.$message.error(result.message,3);
				}
			})
		}
    },
    onbehaviors(e){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}
		var parems = {"filtering":[{"behaviors":e}]};
		ajaxrequest(advertiser_id, AWEMELEVEL,parems).then((res) => {
			var result=res.data;
			if(result.code =="SUCCESS"){
				this.tiktoktalent = result.data.categories;
			}else{
				this.$message.error(result.message,3);
			}
		})
    },
	ontiktokkey(v){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}
        // 抖音达人关键词搜索
		var parems = {"filtering":[{"value":v}]};
		ajaxrequest(advertiser_id, AWEMELEVEL,parems).then((res) => {
			var result=res.data;
			if(result.code =="SUCCESS"){
				this.tiktoktalent = result.data.categories;
			}else{
				this.$message.error(result.message,3);
			}
		})
    },
    onsuperior(e){
        //媒体定向
		this.superior = e.target.value;
		this.autoaudience();
    },
    onconverted(e){
        //过滤时间
        if(e.target.value == 'APP' || e.target.value =='CUSTOMER'){
          this.isconverted=true;
        }else{
          this.isconverted=false;
        }
		this.converted = e.target.value;
		this.autoaudience();
	},
	onextend(e){
		//智能播放
		this.enableds = e.target.value;
		this.autoaudience();
	},
    onarticle(e){
      // 文章分类
	  this.article = e.target.value;
	  this.autoaudience();
    },
    onbrand(e){
      //手机品牌
	  this.brand = e.target.value;
	  this.autoaudience();
    },
    onprice(e){
      //价格按钮
	  this.launchprice = e.target.value;
	  this.autoaudience();
    },
    getTime(){
	  this.nowtime = new Date().toLocaleString();
    },
    // onlaunch(e){
    //   // 价格滑动
    //   if(e ==1){
    //     this.pricearr = [2000, 4000];
    //   }else if(e ==2){
    //     this.pricearr = [4000,6000];
    //   }else if(e ==3){
    //     this.pricearr = [6000,8000];
    //   }else if(e ==4){
    //     this.pricearr = [8000,11000];
    //   }
    // },
    onAfterChange(value){
      // console.log(value);
	  this.strnum = value;
	  this.autoaudience();
    },
    onenabled(e){
	  this.enableds = e.target.value;
	  this.autoaudience();
    },
    onselected(e){
	  this.sceneselect = e;
	//   this.autoaudience();
    },
    onadjust(e){
	  this.adjust = e.target.value;
	  this.autoaudience();
    },
    onschedule(e){
	  this.schedule_type =  e.target.value;
	  this.autoaudience();
    },
    onpackage(v){
        //媒体定向包条件筛选
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}
		var parems = {"filtering":{flow_package_ids:[v]}};

        ajaxrequest(advertiser_id, FLOWPACKAGE,parems).then((res) => {
            var packages=res.data;
            console.log(packages.data.list);
            if(packages.data.list.length > 0){
                packages.data.list.forEach(function(item) {
                  this.packagelist.push({
                        id: item[1].flow_package_id,
                        name:item[1].name,
                    });
                });
            }
        })
		// this.autoaudience();
    },
	listNew(){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

		var citydata = {"parent_id":"0"};
		ajaxparems(CITYGET,citydata).then((res) => {
			var result = res.data;
			if(result.code =="SUCCESS"){
				this.province = result.data
			}
		});

      
		  //查询人群包
		  var dmpparems = {'select_type':1}
      ajaxrequest(advertiser_id, DMPURL,dmpparems).then((res) => {
        var dmp=res.data;
        if(dmp.code =="SUCCESS"){
          this.tagslist = dmp.data.custom_audience_list;
        }else{
          this.$message.error(dmp.message,3);
        }
          })
  
          //媒体包
          ajaxrequest(advertiser_id, FLOWPACKAGE,"").then((res) => {
          var packages=res.data;
        //   console.log(packages);
          if(packages.code =="SUCCESS"){
            this.packagelist = packages.data.list
          }else{
            this.$message.error(packages.message,3);
          }
          })
        
		 //行为类目词
		 var parems = {"action_scene":['E-COMMERCE','NEWS','APP'],'action_days':30};
		 ajaxrequest(advertiser_id, CATEGORYURL,parems).then((res) => {
			 var category=res.data;
			 if(category.code =="SUCCESS"){
				 this.categorieslist = category.data;
			 }else{
				 this.$message.error(category.message,3);
			 }
		 })
 
		 //兴趣类目词
		 var interestparems = {"action_scene":['E-COMMERCE','NEWS','APP'],'action_days':30};
		 ajaxrequest(advertiser_id, INTERESTURL,interestparems).then((res) => {
			 var interest=res.data;
			//  console.log(interest);
			 if(interest.code =="SUCCESS"){
				 this.interestlist = interest.data;
			 }else{
				 this.$message.error(interest.message,3);
			 }
		 })

		 //城市
        var cityparems = {"parent_id":"0"};
        ajaxparems(CITYGET,cityparems).then((res) => {
              var result = res.data;
              this.treeData = result.data
		});
		
		this.spinning = false;
	},

	onestimate(){
		this.audienceloading = true;

		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}
		//受众预估结果
		ajaxrequest(advertiser_id, AUDIENCE,"").then((res) => {
		  var result = res.data;
		  if(result.code =="SUCCESS"){
			this.estimate = result.data;
			this.audienceloading = false;
		  }else{
			this.$message.error(result.message,3);
			this.audienceloading = false;
		  }
		})
	},

	onlocation(e){
		console.log(e);
		this.location_type = e.target.value;
		this.autoaudience();
	},

    autoaudience(){
		this.audienceloading = true;
      // 受众预估结果
      // 城市
	  var parems = {};
		//省
		if(this.citylist.length >0){
			var province = [];
		  this.citylist.forEach((res)=>{
			province.push(res.id);
		  })
		  parems['province'] = province;
        }
		if(this.sontree.length >0){
			var city = [];
			this.sontree.forEach((res)=>{
				city.push(res.id);
			})
			parems['city'] = city;
		}

		if(this.countylist.length >0){
			var countylist = [];
			this.countylist.forEach((res)=>{
				countylist.push(res.id);
			})
			parems['city'] = countylist;
		}
	  //性别
      if(this.gender != 'NONE'){
        parems['gender'] = this.gender;
      }
	  //年龄
      var age = [];
      if(this.label.label1 ==true){
        age.push('AGE_BETWEEN_18_23');
      }
      if(this.label.label2 ==true){
        age.push('AGE_BETWEEN_24_30');
      }
      if(this.label.label3 ==true){
        age.push('AGE_BETWEEN_31_40');
      }
      if(this.label.label4 ==true){
        age.push('AGE_BETWEEN_41_49');
      }
      if(this.label.label5 ==true){
        age.push('AGE_ABOVE_50');
      }
      parems['age'] = age;
	  
	//定向人群包
    if(this.selectedRows.length >0){
		var list = [];
		this.selectedRows.forEach((res)=>{
			list.push(res.custom_audience_id);
		})
		parems['retargeting_tags_include'] = list;
    }
	//排除人群包
    if(this.selectedRowss.length >0){
		var rows = [];
		this.selectedRowss.forEach((res)=>{
			rows.push(res.custom_audience_id);
		})
        parems['retargeting_tags_exclude'] = rows;
    }
      //平台
      var platform = [];
      if(this.label.android ==true){
        platform.push('ANDROID');
      }
      if(this.label.iOS ==true){
        platform.push('IOS');
      }
      if(this.label.PC ==true){
        platform.push('PC');
      }
      parems['platform'] = platform;

      // 网络
      var ac = [];
      if(this.label.wifi ==true){
        ac.push('WIFI');
      }
      if(this.label.twog ==true){
        ac.push('2G');
      }
      if(this.label.threeg ==true){
        ac.push('3G');
      }
      if(this.label.forg ==true){
        ac.push('4G');
      }
      parems['ac'] = ac;
  
      // 运营商
      var carrier = [];
      if(this.label.MOBILE ==true){
        carrier.push('MOBILE');
      }
      if(this.label.UNICOM ==true){
        carrier.push('UNICOM');
      }
      if(this.label.TELCOM ==true){
        carrier.push('TELCOM');
      }
      parems['carrier'] = carrier;

      //新用户
      var activate_type = [];
      if(this.label.WITH_IN_A_MONTH ==true){
        activate_type.push('WITH_IN_A_MONTH');
      }
      if(this.label.ONE_MONTH_2_THREE_MONTH ==true){
        activate_type.push('ONE_MONTH_2_THREE_MONTH');
      }
      if(this.label.THREE_MONTH_EAILIER ==true){
        activate_type.push('THREE_MONTH_EAILIER');
      }
      parems['activate_type'] = activate_type;
      //文章分类
      if(this.rowarticlelist.length >0){
        var article_category = [];
        this.rowarticlelist.forEach((reslist)=>{
          article_category.push(reslist.value);
        })
        parems['article_category'] = article_category;
      }
  
      // 手机品牌
      if(this.rowbrandlist.length >0){
        var device_brand = [];
        this.rowbrandlist.forEach((reslist)=>{
          device_brand.push(reslist.value);
        })
        parems['device_brand'] = device_brand;
      }

	  //兴趣类目
	  if(this.catewordslist.length >0){
		  var ad_tag = [];
		  this.catewordslist.forEach((res)=>{
			ad_tag.push(res.id)
		  })
		  parems['ad_tag'] = ad_tag;
	  }
  
	  //兴趣关键词
	  if(this.datakey.length >0){
		  var interest_tags = [];
		  this.datakey.forEach((res)=>{
			interest_tags.push(res.id);
		  })
		  parems['interest_tags'] = interest_tags;
	  }
    //   if(this.strnum !=''){
    //     parems['strnum'] = this.strnum[0];//手机价格
    //   }
      if(this.rowenabledlist.length >0){
        parems['rowenabledlist'] = this.rowenabledlist;//可放开定向
      }

      parems['district'] = this.district;//地域类型
      if(this.district !='NONE'){
        parems['location_type'] = this.location_type;
      }

	  	var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

      parems['advertiser_id'] = advertiser_id;//广告主账号
      	ajaxrequest(advertiser_id, AUDIENCE,parems).then((res) => {
			var result = res.data;
			if(result.code =="SUCCESS"){
				this.audienceloading = false;
				this.estimate = result.data;
			}else{
				this.audienceloading = false;
				this.$message.error(result.message,3);
			}
        })	  
    },
	tonum(num){
		var sellNum = "";
		var numval = Math.floor(num / 10000);
		if(numval > 9999){
			var numis = Math.floor(num / 100000000);
			sellNum = numis+'亿';
		}else{
			sellNum = numval+'万';
		}
		return sellNum;
	},
    onaction(key){
       if(key =="action_words"){
           console.log(key);
       }
    },
	ondmp(value){
		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
		if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}
		var parems = {'select_type':[value]};
		ajaxrequest(advertiser_id, DMPURL,parems).then((res) => {
			var dmp=res.data;
			dmp.data.custom_audience_list.forEach(function(item) {
				if(item.isdel ==0){
					this.tagslist.push({
						id: item.custom_audience_id,
						name:item.name,
						tag:'自定义'
					});
				}
				// console.log(this.tagslist);
			});
		})
	},
	onChangecity(checkedList) {
		var sid = checkedList.target.value;
		//查询县
		ajaxget("http://localhost:8080/data/city.json").then((res) => {
			var result = res.data;
			this.idv = sid;
			this.county = Object.entries(result);
      	});

      this.indeterminate = !!checkedList.length && checkedList.length < city.length;
      this.checkAll = checkedList.length === city.length;
    },
    onCheckAllChange(e) {
      Object.assign(this, {
        checkedList: e.target.checked ? city : [],
        indeterminate: false,
        checkAll: e.target.checked,
      });
    },
   
    updatename(){
      var nowDate = new Date();
      let date = {
          month: nowDate.getMonth() + 1,
          date: nowDate.getDate(),
      }
      let hour = nowDate.getHours(); // 时
      let minute = nowDate.getMinutes(); // 分
      let second = nowDate.getSeconds(); // 秒
      var newname = this.pricings;
      this.name = newname+'_'+date.month+'_'+date.date+'_'+hour+':'+minute+':'+second;
    },
    cancels() {
      this.$router.push("/promotion/advering/advers");
    },
    determines() {
      this.form.validateFieldsAndScroll((err, values) => {
        var primary = this.primary;
        if (primary == 2) {
          if (values.budget == undefined) {
            this.$message.error("请输入预算值", 3);
            return;
          }
          data.budget = values.budget;
          data.budget_mode = "BUDGET_MODE_DAY";
        } else {
          // data = "";
          data.budget_mode = "BUDGET_MODE_INFINITE";
		}

		var storage=window.localStorage;
		var info = storage.getItem("one");
		var page = JSON.parse(info);
		var advertiser_id = '';
    if(page.type ==3){
			advertiser_id= page.list[0].advertiser_id;
		}else{
			advertiser_id = page.advertiser_id;
		}

        data.campaign_name = values.name;
        data.advertiser_id = advertiser_id;
        data.campaign_id = this.id;
        data.modify_time = this.modify_time;

        var parems = data;
        ajaxnoparams(advertiser_id, EDITADURL, parems).then((res) => {
          var result = res.data;
          if (result.code == "SUCCESS") {
            this.$message
              .success(result.message, 3)
              .then(this.$router.push("/promotion/advering/advers"));
          } else {
            this.$message.error(result.message, 3);
          }
        });
      });
    },
    onChange(checked) {
      this.switchons = checked;
    },
    cancel(){
      // 取消、
      this.$router.push('/promotion/advering/plans')
    },
    onnext(){
      //保存
      this.form.validateFieldsAndScroll((err, values) => {
			this.logging = true;
			//如果是范围删除
			if(this.delivery_range =="DEFAULT"){
				this.$delete(values,'union_video_type');
			}
			values["smart_bid_type"] = this.sceneselect
			if(this.audiencelist.length <=0){
				this.$message.error('请选择定向包',3);
				this.logging = false;
				return;
			}
			for (let is = 0; is < this.audiencelist.length; is++) {
				this.audiencelist[is].audience = { ...this.audiencelist[is].audience,retargeting_tags_include:[],retargeting_tags_exclude:[]}
			}
			var storage=window.localStorage;
			var info = storage.getItem("one");
			var page = JSON.parse(info);
			var advertiser_id = '';
			if(page.type ==3){
				advertiser_id= page.list[0].advertiser_id;
			}else{
				advertiser_id = page.advertiser_id;
			}
			values['audience'] = this.audiencelist;
			values["advertiser_id"] = advertiser_id;
			values["campaign_id"] = this.id;
			if(this.landing_type =="APP"){
				if(values["download_type"] =="EXTERNAL_URL"){
				  	this.$delete(values,'download_url');
				  	if(values["external_url"] ==""){
						this.$message.error("请输入落地页链接", 3);
						this.logging = false;
						return;
					}

					//落地页信息
					if(values['external_url']!=''){
						values['external'] = this.externalurl;
					}

					// if(this.scene ==1 || this.scene ==2){
					// 	if(this.track ==false){
					// 		this.$message.error("请选择转化目标");
					// 		this.logging = false;
					// 		return;
					// 	}else{
					// 		if(values['convert_id'] ==undefined){
					// 			this.$message.error("请选择转化目标");
					// 			this.logging = false;
					// 			return;
					// 		}
					// 	}
					// }
				}
	  
				if(values["download_type"] =="DOWNLOAD_URL"){
					this.$delete(values,'external_url');
					if(values["download_url"] ==""){
						this.$message.error("请输入应用下载链接", 3);
						this.logging = false;
						return;
					}
					
					//应用链接
					// if(values['download_url']!=''){
					// 	values['external'] = this.downloadurl;
					// }

					if(this.scene ==1 || this.scene ==2){
						if(this.track ==false){
							this.$message.error("请选择转化目标");
							this.logging = false;
							return;
						}else{
							if(values['convert_id'] ==undefined){
								this.$message.error("请选择转化目标");
								this.logging = false;
								return;
							}
						}
					}

					if(values["package"] ==""){
						this.$message.error("请输入应用包名", 3);
						this.logging = false;
						return;
					}
				}
			}else if(this.landing_type =="LINK"){
				this.$delete(values,'download_url');
			}

			values['namelist'] = this.namelist;

			values["operation"] = "disable";
			var d = JSON.stringify(values);
			storage.setItem("two",d);
			this.logging = false;
			// console.log(storage.getItem('two'));
			//跳转批量广告创意
        	this.$router.push('/promotion/originality');
		
      });
    },
    imgurl(name) {
      return require("@/assets/img/" + name);
	},
	
	
	//行为 全选
	arr1(){
		this.is_checked_1 = !this.is_checked_1;
		if(this.is_checked_1 == true){
			this.cheakedTrue(this.categorieslist,1);
			this.cheakedTrue(this.arr2,2);
			this.cheakedTrue(this.arr3,3);
		}else{
			this.cheakedFalse(this.categorieslist,this.arr1CheckedIndex,1);
			this.cheakedFalse(this.arr2,this.arr2CheckedIndex,2);
			this.cheakedFalse(this.arr3,this.arr3CheckedIndex,3);
		}
	},

	arrs2(){
		this.is_checked_2 = !this.is_checked_2;
		if(this.is_checked_2 == true){
			this.cheakedTrue(this.arr2);
			this.cheakedTrue(this.arr3);
		}else{
			this.cheakedFalse(this.arr2,this.arr2CheckedIndex);
			this.cheakedFalse(this.arr3,this.arr3CheckedIndex);
		}
	},

	arrs3(){
		this.is_checked_3 = !this.is_checked_3;
		if(this.is_checked_3 == true){
			this.cheakedTrue(this.arr3);
		}else{
			this.cheakedFalse(this.arr3,this.arr3CheckedIndex);
		}
	},
	// 数组全选
	cheakedTrue(arr,num){
		arr.map(v=>{
			v.is_checked = true				
		});
		if(num ==1){
			this.titleArr = arr;
			this.catewords = arr;
		}
	},
	// 数组取消
	cheakedFalse(arr,arrIndex,num){
		console.log(arrIndex);
		arr.map(v=>{
			v.is_checked = false;
			arrIndex = null;			
		});
		if(num ==1){
			this.titleArr = [];
			this.catewords = [];
		}
	},
	//一级栏目
	handleChange1(index){
		this.arr2 = this.categorieslist[index].children;
		this.arr1CheckedIndex = index;
		if(this.is_checked_1){
			this.cheakedTrue(this.arr2);
		}
		this.arr3 = [];
	},
	// 一级勾选栏目
	checked1(index,id){
		this.handleChange1(index);
		let current = this.categorieslist[index];
		current.is_checked= !current.is_checked;
		// 记录选中的组
		let obj = {};
		obj.id = id;
		obj.name = current.name;
		obj.num = current.num;
		console.log(this.titleArr)
		if(current.is_checked){
			this.categorieslist[index].is_checked == true;
			this.titleArr.push(obj);
			this.catewords.push(obj);
			this.cheakedTrue(this.arr2);
			if(this.arr3.length != 0){
				this.cheakedTrue(this.arr3);
			}
			return false	
		}else{
			this.categorieslist[index].is_checked == false;
			this.titleArr.splice(this.titleArr.findIndex(v => id == v.id),1);
			this.catewords.splice(this.catewords.findIndex(v => id == v.id),1);
			this.cheakedFalse(this.arr2,this.arr1CheckedIndex);					
			if(this.arr3.length != 0){
				this.cheakedFalse(this.arr3,this.arr2CheckedIndex)
			}			
		}	
	},
	// 二级栏目
	handleChange2(index){
		this.arr3 = this.arr2[index].children;	
		this.arr2CheckedIndex = index;	
		if(this.arr2[this.arr2CheckedIndex].is_checked){
			this.cheakedTrue(this.arr3);
		}
	},
	// 二级勾选栏目
	checked2(index,id){
		this.handleChange2(index);
		let current = this.arr2[index];
		current.is_checked = !current.is_checked;
		let obj = {};
		obj.id = id;
		obj.name = current.name;
		obj.num = current.num;
		obj.parentId = this.categorieslist[this.arr1CheckedIndex].id;
		
		if(current.is_checked){
			this.titleArr.push(obj);
			this.catewords.push(obj);
			this.cheakedTrue(this.arr3);
		}else{
			this.titleArr.splice(this.titleArr.findIndex(v => id == v.id),1);
			this.catewords.splice(this.catewords.findIndex(v => id == v.id),1);

			this.cheakedFalse(this.arr3,this.arr2CheckedIndex);
		}
		// console.log(this.arr2[index].is_checked);
		if(!this.arr2[index].is_checked){
			this.arr2CheckedIndex = null;
		}
		this.checkedArr2HasIsChecked();
		this.isCheackedArr();	
	},
	
	// 检查第二层数组是否全部为false
	checkedArr2HasIsChecked(){
		let arrIsChecked = [];
		this.arr2.map(v => {
		   arrIsChecked.push(v.is_checked)
		});
		if(arrIsChecked.includes(true)){
			this.categorieslist[this.arr1CheckedIndex].is_checked = true;
		}else{
			this.categorieslist[this.arr1CheckedIndex].is_checked = false;
		}
	},
	handleChange3(index){
		console.log(index);
	},
	checked3(index,id){
		let current = this.arr3[index];
		let arr2sChecked = [];
		current.is_checked = !current.is_checked;
		let obj = {};
		obj.id = id;
		obj.name = current.name;
		obj.num = current.num;
		obj.parentId = this.arr2[this.arr1CheckedIndex].id;
		
		if(current.is_checked){
			this.titleArr.push(obj);
			this.catewords.push(obj);
			this.arr3CheckedIndex = index;
		}else{
			this.arr3CheckedIndex = null;
			this.titleArr.splice(this.titleArr.findIndex(v => id == v.id),1);
			this.catewords.splice(this.catewords.findIndex(v => id == v.id),1);
		}
		this.arr3.map(v => {
		   arr2sChecked.push(v.is_checked)
		});
		if(arr2sChecked.includes(true)){
			this.categorieslist[this.arr1CheckedIndex].is_checked = true;
			this.arr2[this.arr2CheckedIndex].is_checked = true;
		}else{
			this.checkedArr2HasIsChecked();
			this.arr2[this.arr2CheckedIndex].is_checked = false;
		}
		this.isCheackedArr2()	
	},
	// 
	addCheckedAll(nowArr,parentArr){
		nowArr.map(v => {
			if(v.is_checked){						
				let obj = {};
				obj.id = v.id;
				obj.name = v.name;
				obj.num = v.num;
				obj.parentId = parentArr.id;
				this.titleArr.push(obj);
				this.catewords.push(obj);
			}
			
		});
		let newobj = {};
		 this.titleArr = this.titleArr.reduce((preVal, curVal) => {
			newobj[curVal.id] ? '' : newobj[curVal.id] = preVal.push(curVal); 
			return preVal 
		}, []) 
	},
	isCheackedArr2(){
		let checkedArr = [];
		this.arr3.map(v => {
			checkedArr.push(v.is_checked);
		});
		if(checkedArr.includes(false)){
			console.log('其中一个没有选中');
			this.addCheckedAll(this.arr3,this.arr2[this.arr2CheckedIndex]);
			return false;
		}
		console.log('都选中');
		let obj = {};
		obj.id = this.arr2[this.arr2CheckedIndex].id;
		obj.name = this.arr2[this.arr2CheckedIndex].name;
		obj.num = this.arr2[this.arr2CheckedIndex].num;
		obj.parentId = this.categorieslist[this.arr1CheckedIndex].id;
		this.titleArr.push(obj);
		this.catewords.push(obj);
		console.log('parentArr',obj)
		for (let i = this.titleArr.length - 1; i >= 0; i--) {
		    if (this.titleArr[i].parentId === this.arr2[this.arr2CheckedIndex].id) {
				this.titleArr.splice(i, 1);
				this.catewords.splice(i, 1);
		    }
		}
		console.log('this.titleArr',this.titleArr)
	},
	// 遍历所有素组，第二第三层数组，除了没有选中的其余都记录下来
	isCheackedArr(){
		let checkedArr = [];
		this.arr2.map(v => {
			checkedArr.push(v.is_checked)
		});
		if(checkedArr.includes(false)){
			console.log('其中一个没有选中');
			this.addCheckedAll(this.arr2,this.categorieslist[this.arr1CheckedIndex]);
			return false
		}
		console.log('都选中');
		let obj = {};
		obj.id = this.categorieslist[this.arr1CheckedIndex].id;
		obj.name = this.categorieslist[this.arr1CheckedIndex].name;
		obj.num = this.categorieslist[this.arr1CheckedIndex].num;
		obj.parentId = this.categorieslist[this.arr1CheckedIndex].parentId;
		this.titleArr.push(obj);
		this.catewords.push(obj);
		for (let i = this.titleArr.length - 1; i >= 0; i--) {
		    if (this.titleArr[i].parentId === this.data[this.arr1CheckedIndex].id) {
		        this.titleArr.splice(i, 1);
		        this.catewords.splice(i, 1);
		    }
		}
		console.log('this.titleArr2',this.titleArr)
	},


		// 兴趣 全选
		onarr1(){
			this.is_checked_s1 = !this.is_checked_s1;
			if(this.is_checked_s1 == true){
				this.cheakedTrues(this.interestlist,1);
				this.cheakedTrues(this.array2,2);
				this.cheakedTrues(this.array3,3);
			}else{
				this.cheakedFalses(this.interestlist,this.array1CheckedIndex,1);
				this.cheakedFalses(this.array2,this.array2CheckedIndex,2);
				this.cheakedFalses(this.array3,this.array3CheckedIndex,3);
			}
			this.autoaudience();
		},
	
		onarr2(){
			this.is_checked_s2 = !this.is_checked_s2;
			if(this.is_checked_s2 == true){
				this.cheakedTrues(this.array2);
				this.cheakedTrues(this.array3);
			}else{
				this.cheakedFalses(this.array2,this.array2CheckedIndex);
				this.cheakedFalses(this.array3,this.array3CheckedIndex);
			}
			this.autoaudience();
		},
	
		onarr3(){
			this.is_checked_s3 = !this.is_checked_s3;
			if(this.is_checked_s3 == true){
				this.cheakedTrues(this.array3);
			}else{
				this.cheakedFalses(this.array3,this.array3CheckedIndex);
			}
			this.autoaudience();
		},
		// 数组全选
		cheakedTrues(arr,num){
			arr.map(v=>{
				v.is_checked = true				
			});

			if(num ==1){
				this.titleArray =arr;
				this.catewordslist = arr;
			}

		},
		// 数组取消
		cheakedFalses(arr,arrIndex,num){
			console.log(arrIndex);
			arr.map(v=>{
				v.is_checked = false;
				arrIndex = null;			
			});

			if(num ==1){
				this.titleArray = [];
				this.catewordslist = [];
			}

		},

		//一级栏目
		handleChanges1(index){
			this.array2 = this.interestlist[index].children;
			this.array1CheckedIndex = index;
			if(this.is_checked_s1){
				this.cheakedTrues(this.array2);
			}
			this.array3 = [];
			this.autoaudience();
		},
		// 一级勾选栏目
		checkeds1(index,id){
			this.handleChanges1(index);
			let current = this.interestlist[index];
			current.is_checked= !current.is_checked;
			// 记录选中的组
			let obj = {};
			obj.id = id;
			obj.name = current.name;
			obj.num = current.num;
			if(current.is_checked){
				this.interestlist[index].is_checked == true;
				this.titleArray.push(obj);
				this.catewordslist.push(obj);
				this.cheakedTrues(this.array2);
				if(this.array3.length != 0){
					this.cheakedTrues(this.array3);
				}
				return false	
			}else{
				this.interestlist[index].is_checked == false;
				this.titleArray.splice(this.titleArray.findIndex(v => id == v.id),1);
				this.catewordslist.splice(this.catewordslist.findIndex(v => id == v.id),1);
				this.cheakedFalses(this.array2,this.array1CheckedIndex);					
				if(this.array3.length != 0){
					this.cheakedFalses(this.array3,this.array2CheckedIndex)
				}			
			}	
		},
		// 二级栏目
		handleChanges2(index){
			this.array3 = this.array2[index].children;	
			this.array2CheckedIndex = index;	
			if(this.array2[this.array2CheckedIndex].is_checked){
				this.cheakedTrues(this.array3);
			}
			this.autoaudience();
		},
		// 二级勾选栏目
		checkeds2(index,id){
			this.handleChanges2(index);
			let current = this.array2[index];
			current.is_checked = !current.is_checked;
			let obj = {};
			obj.id = id;
			obj.name = current.name;
			obj.num = current.num;
			obj.parentId = this.interestlist[this.array1CheckedIndex].id;
			
			if(current.is_checked){
				this.titleArray.push(obj);
				this.catewordslist.push(obj);
				this.cheakedTrues(this.array3);
			}else{
				this.titleArray.splice(this.titleArray.findIndex(v => id == v.id),1);
				this.catewordslist.splice(this.catewordslist.findIndex(v => id == v.id),1);
				this.cheakedFalses(this.array3,this.array2CheckedIndex);
			}
			// console.log(this.arr2[index].is_checked);
			// if(!this.arr2[index].is_checked){
			// 	this.arr2CheckedIndex = null;
			// };
			this.checkedArr2HasIsCheckeds();
			this.isCheackedArrs();	
		},
		
		// 检查第二层数组是否全部为false
		checkedArr2HasIsCheckeds(){
			let arrIsChecked = [];
			this.array2.map(v => {
			   arrIsChecked.push(v.is_checked)
			});
			if(arrIsChecked.includes(true)){
				this.interestlist[this.array1CheckedIndex].is_checked = true;
			}else{
				this.interestlist[this.array1CheckedIndex].is_checked = false;
			}
		},
		handleChanges3(index){
			console.log(index);
		},
		checkeds3(index,id){
			let current = this.array3[index];
			let array2sChecked = [];
			current.is_checked = !current.is_checked;
			let obj = {};
			obj.id = id;
			obj.name = current.name;
			obj.num = current.num;
			obj.parentId = this.arr2[this.array1CheckedIndex].id;
			
			if(current.is_checked){
				this.titleArray.push(obj);
				this.catewordslist.push(obj);
				this.array3CheckedIndex = index;
			}else{
				this.array3CheckedIndex = null;
				this.titleArray.splice(this.titleArray.findIndex(v => id == v.id),1);
				this.catewordslist.splice(this.catewordslist.findIndex(v => id == v.id),1);
			}
			this.array3.map(v => {
			   array2sChecked.push(v.is_checked)
			});
			if(array2sChecked.includes(true)){
				this.interestlist[this.array1CheckedIndex].is_checked = true;
				this.array2[this.array2CheckedIndex].is_checked = true;
			}else{
				this.checkedArr2HasIsChecked();
				this.array2[this.array2CheckedIndex].is_checked = false;
			}
			this.isCheackedArrs2()	
		},
		// 
		addCheckedAlls(nowArr,parentArr){
			nowArr.map(v => {
				if(v.is_checked){						
					let obj = {};
					obj.id = v.id;
					obj.name = v.name;
					obj.num = v.num;
					obj.parentId = parentArr.id;
					this.titleArray.push(obj);
					this.catewordslist.push(obj);
				}
				
			});
			let newobj = {};
			 this.titleArray = this.titleArray.reduce((preVal, curVal) => {
				newobj[curVal.id] ? '' : newobj[curVal.id] = preVal.push(curVal); 
				return preVal 
			}, []) 
		},
		isCheackedArrs2(){
			let checkedArr = [];
			this.array3.map(v => {
				checkedArr.push(v.is_checked);
			});
			if(checkedArr.includes(false)){
				console.log('其中一个没有选中');
				this.addCheckedAlls(this.array3,this.array2[this.array2CheckedIndex]);
				return false;
			}
			console.log('都选中');
			let obj = {};
			obj.id = this.array2[this.array2CheckedIndex].id;
			obj.name = this.array2[this.array2CheckedIndex].name;
			obj.num = this.array2[this.array2CheckedIndex].num;
			obj.parentId = this.interestlist[this.array1CheckedIndex].id;
			this.titleArray.push(obj);
			this.catewordslist.push(obj);
			console.log('parentArr',obj)
			for (let i = this.titleArray.length - 1; i >= 0; i--) {
			    if (this.titleArray[i].parentId === this.array2[this.array2CheckedIndex].id) {
			        this.titleArray.splice(i, 1);
			        this.catewordslist.splice(i, 1);
			    }
			}
			console.log('this.titleArr',this.titleArray)
			
		},
		// 遍历所有素组，第二第三层数组，除了没有选中的其余都记录下来
		isCheackedArrs(){
			let checkedArr = [];
			this.array2.map(v => {
				checkedArr.push(v.is_checked)
			});
			if(checkedArr.includes(false)){
				console.log('其中一个没有选中');
				this.addCheckedAlls(this.array2,this.interestlist[this.array1CheckedIndex]);
				return false
			}
			console.log('都选中');
			let obj = {};
			obj.id = this.interestlist[this.array1CheckedIndex].id;
			obj.name = this.interestlist[this.array1CheckedIndex].name;
			obj.num = this.interestlist[this.array1CheckedIndex].num;
			obj.parentId = this.interestlist[this.array1CheckedIndex].parentId;
			this.titleArray.push(obj);
			this.catewordslist.push(obj);
			for (let i = this.titleArray.length - 1; i >= 0; i--) {
			    if (this.titleArray[i].parentId === this.interestlist[this.array1CheckedIndex].id) {
			        this.titleArray.splice(i, 1);
			        this.catewordslist.splice(i,1);
			    }
			}
			console.log('this.titleArr2',this.titleArray)
		},

  },
  computed: {
	...mapGetters('account', ['user']),
	is_checked_1(){
		let boo = false;
		let arrChecked = [];
		this.categorieslist.map(v =>{
			arrChecked.push(v.is_checked);
		})
		if(arrChecked.includes(true)){
			boo = true
		}
		return boo;
	},
	is_checked_2(){
		let boo = false;
		let arrChecked = [];
		this.arr2.map(v =>{
			arrChecked.push(v.is_checked);
		})
		
		if(arrChecked.includes(true)){
			boo = true
		}
		return boo;
	},
	is_checked_3(){
		let boo = false;
		let arrChecked = [];
		this.arr3.map(v =>{
			arrChecked.push(v.is_checked);
		})
		if(arrChecked.includes(true)){
			boo = true
		}
		return boo;
	},

	is_checked_s1(){
		let boo = false;
		let arrChecked = [];
		this.interestlist.map(v =>{
			arrChecked.push(v.is_checked);
		})
		if(arrChecked.includes(true)){
			boo = true
		}
		return boo;
	},
	is_checked_s2(){
		let boo = false;
		let arrChecked = [];
		this.array2.map(v =>{
			arrChecked.push(v.is_checked);
		})
		
		if(arrChecked.includes(true)){
			boo = true
		}
		return boo;
	},
	is_checked_s3(){
		let boo = false;
		let arrChecked = [];
		this.array3.map(v =>{
			arrChecked.push(v.is_checked);
		})
		if(arrChecked.includes(true)){
			boo = true
		}
		return boo;
	},

    appselection(){
      return {
        onChange: (selectedRowKeys, selectedRows) => {
			    // this.selectedRows = selectedRows;
          console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
        },
      };
    },
    rowSelection() {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
			this.selectedRows = selectedRows;
			this.autoaudience();
        //   console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
        },
      };
	},
	rowSelections() {
		return {
		onChange: (selectedRowKeys, selectedRows) => {
			this.selectedRowss = selectedRows;
			this.autoaudience();
		// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
		},
      };
    },
    rowcategories() {
        // 行为类目词
		return {
		onChange: (selectedRowKeys, selectedRows) => {
            if(selectedRows.length !=0){
                var arr = selectedRows.reverse();
                console.log(arr);
                // console.log(arr[0]);           
                // this.soncategories[0].title = arr[0].name;
                // console.log(arr[0]);

                // this.soncategorieslist = arr.children;
            }
		// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
		},
      };
	},
	
	rowtiktoktalent(){
		return {
			onChange: (selectedRowKeys, selectedRows) => {
				this.rowtiktoktalentlist = selectedRows;
				var count = this.sontiktoktalent.length;
				console.log(count);
				if(selectedRows.length !=0){
					if(count !=selectedRows.length){
						var arr = selectedRows.reverse();
						var list = [];
						if(arr[0].son.length >0){
							arr[0].son.forEach((res)=>{
								list.push({
									id:res.id,
									value:res.value,
									name:res.value,
									fans_num_str:res.fans_num_str,
									son:res.children
								})
								this.sontiktoktalent = list;
							})
						}
						// this.sontiktoktalent = arr[0].son;
						
					}
				}else{
					this.sontiktoktalent = [];
				}
			},
		}
	},
	rowsontiktoktalent(){
		return {
			onChange: (selectedRowKeys, selectedRows) => {
				var count = this.threetiktoktalent.length;
				console.log(count);
				if(selectedRows.length !=0){
					if(count !=selectedRows.length){
						var arr = selectedRows.reverse();
						var list = [];
						if(arr[0].son.length >0){
							arr[0].son.forEach((res)=>{
								list.push({
									id:res.id,
									value:res.value,
									name:res.value,
									fans_num_str:res.fans_num_str,
									son:res.children
								})
								this.threetiktoktalent = list;
							})
						}
						// this.sontiktoktalent = arr[0].son;
					}
				}
			},
		}
	},

    rowsoncategories() {
		return {
		onChange: (selectedRowKeys, selectedRows) => {
			this.rowcategorieslist = selectedRows;
		// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
		},
      };
    },
    rowpackage(){
        return {
            onChange: (selectedRowKeys, selectedRows) => {
               
                this.rowpackagelist = selectedRows;
            // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
            },
        };
    },
    rowpackages(){
        return {
            onChange: (selectedRowKeys, selectedRows) => {
                this.rowpackagelists = selectedRows;
            // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
            },
        };
    },
    rowarticle(){
      return {
        onChange: (selectedRowKeys, selectedRows) => {
            this.rowarticlelist = selectedRows;
			this.autoaudience();
        // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
        },
      };
    },

    rowbrand(){
      return {
        onChange: (selectedRowKeys, selectedRows) => {
            this.rowbrandlist = selectedRows;
			this.autoaudience();
        // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
        },
      };
    },

    rowenabled(){
      return {
        onChange: (selectedRowKeys, selectedRows) => {
            this.rowenabledlist = selectedRows;
        // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRowss);
        },
      };
	},
	
	rowSelectiondatas() {
		//省
		return {
		  	onChange: (selectedRowKeys, selectedRows) => {
				console.log(selectedRows);
			  var count = this.treeData.length;
			  this.citylist =selectedRows;
			   if(selectedRows.length !=0){
				  var arr = selectedRows.reverse();
					
				  if(count != selectedRows.length){
					this.sontable = true;
					this.pixel = '180px';
					this.soncolumns[0].title = arr[0].name
					  var cityparems = {"parent_id":arr[0].id};
					  ajaxparems(CITYGET,cityparems).then((res) => {
						  var result = res.data;
						  this.sontreeData = result.data
					  });
				  }else{
					  this.sontable = false;
					  this.pixel = '500px';
				  }
			   }else{
				  this.grandtable = false;
				  this.sontable = false;
				  this.pixel = '500px'; 
			   }
			   this.autoaudience();
		  	},
		};
	  },
	  sonrowSelection() {
		  //市
		return {
		  onChange: (selectedRowKeys, selectedRows) => {
			  var count = this.sontreeData.length;
			   if(selectedRows.length !=0){
					var arr = selectedRows.reverse(); 
					this.sontree = selectedRows;
					if(count != selectedRowKeys.length){
							this.grandtable = true;
							 this.grandcolumns[0].title = arr[0].name
						  var cityparems = {"parent_id":arr[0].id};
						  ajaxparems(CITYGET,cityparems).then((res) => {
							  var result = res.data;
							  this.grandtreeData = result.data
						  });
					}else{
							this.grandtable = false;
					}
			   }
			   this.autoaudience();
		  },
		};
	  },
}
};